1
votes

I have an aspx page in which i have 3 asp.net text boxes and 1 asp.net button control.I want to do a client side validation before the post back happens when i click on the button . ie ; If the the page passes the validation check,then only i need to invoke the server side button click event.Can any one help me ? Thanks in advance

2

2 Answers

2
votes

Define JS function:

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

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

If JS function will return false, postback will be canceled.

0
votes

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

Don't forget to valiate on the server-side too, as Javascript may be disabled.