javascriptjquerywebshim

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.


Solution

  • 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 (i.e.: 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');