开发者

Submit problems with jQuery validation plugin

开发者 https://www.devze.com 2022-12-19 08:15 出处:网络
Im having a master page开发者_JAVA技巧 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

Im having a master page开发者_JAVA技巧 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!


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


retun false for your onSubmit event if any error occurs

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号