jQuery validate for placeholder text
Sometimes you require an input to be required, but if you use placeholder text, or pre-fill with default you still need to validate against the placeholder.
This custom method will do just that. Add this before the call to validate the form.
$.validator.addMethod("placeholder", function (value, element) {
if (value == $(element).attr('placeholder')) {
return false;
} else {
return true;
}
});
Written by Leon Barrett
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Validate
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#