I’m using the jQuery validation plugin found here:
http://plugins.jquery.com/project/validate
In my form I have default values saying “Please enter your name” in the name field. I’d like a custom validation to ensure that a user has not left this when they submit the form.
Here’s the jQuery i’m using…. Can someone please help me with the missing code.
Thanks 🙂
$(document).ready(function(){
$.validator.addMethod('defaultText', function(value, element) {
// need code to go here!!!
}, 'Please enter your first name');
$("#commentForm").validate({
rules: {
firstname: {
required: true,
defaultText: true,
},
email: {
required: true,
email: true
}
},
messages: {
firstname: "Please enter your first name",
email: "Please enter a valid email address"
}
});
});
Figured it out….
This makes whatever is in the field by default – not be accepted as valid input!