开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜