views:

64

answers:

6

Hi, I'm using the validation plugin for jquery: http://docs.jquery.com/Plugins/Validation.

I want to know how would I exempt a field to be validated? Currently all fields inside the form are automatically checked.

A: 

Are you using some sort of server side technology? The validation library needs to have rules set, and if you are doing this in strictly javaScript (jQuery) it is manual.

UPDATE: You can remove rules with the following: http://docs.jquery.com/Plugins/Validation/rules#.22remove.22rules

Place the following at the end of the body.

$("selector").rules("remove");
Dustin Laine
nope. and the field that I want to be exempted is not in the rules [meaning I didn't add any because I didn't want it validated].
wnoveno
Please paste your source code.
Dustin Laine
A: 

It depends on class attribute. See examples:

This field is required and email format: it cannot be empty

input class="required email"

This field is NOT required and email format: it can be empty

input class="email"

This field is NOT required and doesnt have format: it can be empty

input class=""
Sergei
This does not work as I've added an image to the label that the plugin attaches to each element (x or check).
wnoveno
so show us the complete code.
Sergei
+1  A: 

I am not sure if this will help since the element that I want to exempt is not included (obviously :) )

  $("#contactForm").validate({
      rules: {
                        first_name:{required: true,charsonly:true,minlength: 1 },
                        last_name:{required:true,charsonly:true,minlength: 1 },
                        birthday:{required:true,min:1,max:31 },
                        birthmonth:"required",
                        birthyear:"required",
                        username: {required: true,minlength:1,maxlength:32,username:true,notChinese:true,noSpecial:true},
                        password1:{required:true,minlength: 5,maxlength: 10, alphaNum: true },
                        password2:{required:true,minlength: 5,maxlength: 10, alphaNum: true, equalTo: "#password1"},
                        currency:"required",
                        address:{required: true,noSpecial:true,minlength:2},
                        city:{required: true,noSpecial:true,minlength:2},
                        state:{noSpecial:true},
                        countrycode:"required",
                        zip:{required:true,zipTest:true},
                        email:{required:true,email:  true},
                        confirmemail:{required: true,equalTo:  "#email",email:true},
                        phone:{required: true,minlength:6,maxlength:20,phoneUS:true},
                        cellphone:{required: true,minlength:6,maxlength:20,phoneUS:true},
                        custom06:{acceptIM:true}

      } });
wnoveno
if you notice I also created custom validation methods. But I think this has nothing to do with the problem.
wnoveno
A: 

Found it. I used the ignore validation method.

wnoveno
A: 

You could set your own messages:

$("#contactForm").validate({
      rules: {
         input1: required,
         input2: required,
         no-validation: required,
         input4: required,
      },
      messages: {
         no-validation: ''
      }
});

Just put an empty string for the field you don´t want to show any message for..

samuel02
A: 

Here's the code

$("#myform").validate({
   ignore: ".ignore"
})
wnoveno