[jQuery] validate : help with required code

2008-11-06 Thread Chuck Cheeze

I have a form field that by default has the value "First".  When the
user clicks into the field it clears that value, and if they type
nothing, when they blur the field it replaces "First".  You've all
seen this.
I want the validate plugin to say this field is required if the value
onsubmit is "First".  Can't seem to make it work.
[code]
// validate signup form on keyup and submit
$("#contactform").validate({
rules: {
name_first: {
required: function(element) {
return $
('#name_first').val() != "First";
}
},
name_last: "required",
country: "required",
otherinfo: "required",
email: {
required: true,
email: true
}
}
});

[/code]
Once I do that, I'll use the same code for last name.


[jQuery] [validate] Help with required code

2008-11-06 Thread Chuck Cheeze

I have a form field that by default has the value "First".  When the
user clicks into the field it clears that value, and if they type
nothing, when they blur the field it replaces "First".  You've all
seen this.

I want the validate plugin to say this field is required if the value
onsubmit is "First".  Can't seem to make it work.

[code]
// validate signup form on keyup and submit
$("#contactform").validate({
rules: {
name_first: {
required: function(element) {
return $('#name_first').val() 
!= "First";
}
},
name_last: "required",
country: "required",
otherinfo: "required",
email: {
required: true,
email: true
}
}
});


[/code]

Once I do that, I'll use the same code for last name.