开发者

Is it possible to change the error class name on jQuery validate?

开发者 https://www.devze.com 2023-03-04 22:38 出处:网络
I want to change the class that jQuery Validate applies to inputs that have an error Change this <input id=\"firstname\" name=\"firstname\" type=\"text\" value=\"\" maxlength=\"100\"

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

Change this

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

to this

<开发者_开发百科input id="firstname" name="firstname" type="text" value="" maxlength="100" 
class="customErrorClass">


Try specifying the errorClass property:

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


The one can use code as following 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

精彩评论

暂无评论...
验证码 换一张
取 消