jQuery Validate Array Full Validation Problem

  • 2021-07-10 18:41:14
  • OfStack

jquery validate aside from efficiency, the function is relatively complete, the expansion is relatively simple and easy to use. But it can't cover everything. Here's an example

There are many name [] in html, and each parameter should be verified whether it is empty. At this time, if you use required: true directly, you can't verify it all, as long as there is one value in this array.


//if ( this.name in rulesCache || !validator.objectLength($(this).rules()) ) {
 //  return false;
 //}

Modify jquery. validate. js to find the code above and comment it out.

There is also a problem with this change. If you want to use the original function, that is, array, you can't use it if you pass one verification. In this case, the jquery validate addmethod method can be used. In this way, all the problems will be solved.


Related articles: