简体   繁体   中英

WebShim: Show all the error messages at once for the form validation

I need to show all the error messages at once for the form validation instead of showing one error message at a time. Is there any option to do it.

In short you can't. And in 99% the errors do exclude each other.

But you might be able to build it your own. In all cases you need to get the validity object to get all error types, then you can do the following:

  1. In case you are using the descriptive API to define the errormessages (ie: data-errmessage attribute or .ws-errorbox element ). You can use the getErrorMessage method:

//<input data-errormessage-type-mismatch="type mismatch" data-errormessage-value-missing="value missing" /> $('input').getErrorMessage('typeMismatch');

  1. In case you are using customMessages option, you can use webshims.createValidationMessage , which takes a DOM element and the name of the error:

webshims.createValidationMessage($('input')[0], 'typeMismatch');

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