Is it possible to change the class name of an error when checking jQuery?

I want to change the class that jQuery Validate applies to inputs with an error

Change it

<input id="firstname" name="firstname" type="text" value="" maxlength="100" class="error"> 

to that

 <input id="firstname" name="firstname" type="text" value="" maxlength="100" class="customErrorClass"> 
+7
source share
2 answers

Try specifying the errorClass property:

 $('.selector').validate({ errorClass: 'customErrorClass', rules: { ... }, messages: { ... } }); 
+25
source

You can use the following code for Custom Css

 <style> .myErrorCssClass { border: solid 1px #ff0000; } </style> <script> $('#form1').validate({ errorClass: "myErrorCssClass", rules: { Name: { required: true, minlength: 3, maxlength: 10 }, LastName: { required: true } } }) </script> 
0
source

Source: https://habr.com/ru/post/887840/


All Articles