简体   繁体   中英

JavaScript form validation library that supports custom rules with flexible callbacks

It seems jQuery validation plugin only supports validation rules for submission check. What if I want callbacks instead of submission when certain rules are satisfied, how can this be done in the plugin?

For eg I might want to display a message if every field in the form is filled, and another message if not. I want to bind this to field change event as well as submission. But as long as a required subset of fields are filled, the form can be submitted regardless of whether every field is filled.

Or is there some library that can do this? Thanks for any help!

jquery-validate allows you to supply your own submitHandler , which gets called if the form validates instead of submitting the form. This callback can display a message and then submit the form for real.

Documentation of validate options

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