jQuery验证更改了未验证的元素的类

时间:2014-06-14 16:37:55

标签: javascript jquery validation

好的,所以我要做的是在验证后将输入的标签类更改为绿色。除非你推荐,否则我没有看到任何错误类别的需要。

问题在于,一旦验证该类自动为绿色。我用不同的ID和类来尝试这个。

这里是URL所以你可以看到我想要的东西。

$(document).ready(function() {

jQuery.validator.setDefaults({
success: function(label) {

$("#fnameLabel").css("color", "#18bc9c");

},


submitHandler: function(form) {alert("valid form");}

});


$("#contactForm").validate({
onkeyup: function(element) { 
 $(element).valid();
   },






  rules: {
     fname: { 
       required: true,
       minlength: 2,
       maxlength: 20,
     },
     lname: {
       required: true,
       minlength: 2,
       maxlength: 20
     },
     email: {
       required: true,
       email: true
     },
     ts: {
       required: true
     },
     message: {
       required: true,
       minlength: 20,
       maxlength: 300

     }


 },


 messages: {
   fname: {
     required: "Please enter a name.",
     minlength: $.format("At least {0} characters required."),
     maxlength: $.format("Maximum {0} characters allowed.")
   },
   lname: {
     required: "Please enter a name",
     minlength: $.format("At least {0} characters required."),
     maxlength: $.format("Maximum {0} characters allowed.")
   },
   email: {
     required: "Please enter an email address.",
     email: "Please enter a valid email address."
   },
   ts: {
     required: "This field is required."
   },
   message: {
     required: "This field is required.",
     minlength: $.format("At least {0} characters required."),
     maxlength: $.format("Maximum {0} characters allowed.")

   }




},







  });



 });

0 个答案:

没有答案