views:

58

answers:

2

Hey!

Im having a master page form which i validate. I add code inside the asp:content tag (validation rules code). The validation is working correctly, the only problem i have is that when i click my "save" button i can see the validation errors come up (correctly) but the button still causes a postback and performs its server side code.

I thought that the server code execution would be halted if the form vad invalid.

Any tips on this matter? I dont want the "save" button to run its server side code if any validation error occurs, just like the asp requiredFieldValidator works.

Thanks in advance!

A: 

retun false for your onSubmit event if any error occurs

yanoo
A: 

I assume its an asp:button you are submitting with? If so, try setting the OnClientClick property to something like thids -- OnClientClick="return yourValidationFunction()" />

Your javascript validation code would work something like this

function yourValidationFunction(){
  if(something is not valid)
    return false;
  else
    return true;
}

If you could post a code example it would be easier to give a more detailed answer

TGuimond
thanks, it works :)
Andreas
Glad I could help!
TGuimond