简体   繁体   中英

How to let Validation control and custom javascript validation function work together?

I'm developing a web application. At first I use validation control to do required field validation, later I need to add some custom function to do the validation but still need required field validation. The problem is I found after I add onclientcliek event of the submit button, the previous validation control does not fired. Is there a way that could let both the validation control and my javascript function work before submit the form? Thank you for your time.

make sure you have an ID on your submit button and try and put something like this in your document.ready function:

$("#YourSubmitButtonId").click(function(){
       yourValidationFunction();
       return false;
 });

Use CustomValidator Control. It is pretty easy to configure your own Client-side Validation. More info and an example here . Both validation controls can then work side by side.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM