ASP.NET client side validation and post back

I have an aspx page where I have 3 asp.net textboxes and 1 asp.net control. I want to do client side validation before the message appears when I click a button. those.; If the page passes the validation check, then only I need to call the server side button click button. Can anyone help me? thanks in advance

+1


a source to share


2 answers


Define JS function:

function validate(){
    //perform some validation
    return $("#myTextbox").val()=="";
}

      



call it on the control button onclick event = "return DoValidation ();"

If the JS function returns false, the postback will be canceled.

+2


a source


If you want to integrate with ASP.net validation, you need to register your Javascript validator using the RegisterValidator declaration .



Don't forget to dare on the server side as well, as Javascript can be disabled.

0


a source







All Articles