in my form fields i've got watermark text that disappears when the user is typing something in them.
but then, i cannot use jquery validation plugin http://docs.jquery.com/Plugins/Validation#Example for checking that the user has typed something in the fields cause in either way, they will contain text.
so how can i validate that the user type something when they already conta开发者_如何学运维in watermark text and the plugin will assume they are filled.
You could store the watermark text for each field somewhere (For example the rel
attribute of the element, or in the title
if the watermark text is somthing like "enter your name here", or in a custom JS array for 100% clean and valid HTML) and write your own validation method that checks whether the field's content is equal to the default value.
See Plugins/Validation/Validator/addMethod on how to implement your own validation methods.
you must use addmethod:
jQuery.validator.addMethod("watermarkmethod", function(value, element) {
return this.optional(element) || value != 'your watermark text';
}, "Please do not leave empty");
精彩评论