Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Friends,
Today i faced a situation, where I'm calling javascript function on button event and at the same time the validation summary must be called called.

Example:
<asp:Button ID="btnAddCandidate" runat="server" Text="Submit" CausesValidation="True"
                        ValidationGroup="1" OnClick="btnAddCandidate_Click" OnClientClick="validateResume();"/>


Javascript Code:
function validateResume(){
        var hdn = document.getElementById('lnkbtnViewResume');
        if(hdn.style.visibility=='hidden')
        document.getElementById('lblresume').innerHTML="<ul><li>Please Upload Resume</li></ul>";
    }


Problem is both are not working simultaneously.

Any solution??
Posted
Updated 23-Sep-12 20:47pm
v2

1 solution

This is how it solved the problem

C#
<asp:Button ID="btnAddCandidate" runat="server" Text="Submit" CausesValidation="True"
                        ValidationGroup="1" OnClick="btnAddCandidate_Click" OnClientClick="return validateResume();"/>


C#
function validateResume(){


        var hdn = document.getElementById('lnkbtnViewResume');
        if(hdn.style.visibility=='hidden')
        {
        document.getElementById('lblresume').innerHTML="<ul><li>Please Upload Resume</li></ul>";
        Page_ClientValidate();
        return false;
        }
        else
        {
        Page_ClientValidate();
          return true;

}

     }


Page_ClientValidate() event calls the page validation event.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900