text - jQuery Validator's "required" not working when value is set at statup -


I have a problem with jQuery validation. I want to use the "required" property on a text input. Does not do when the input has defined value attribute by HTML code (tested on Firefox (3.5), and on IE 8 - this works a little better on IE).

Story: 1. Page Load; 2. The value is clear; 3. Focus changed. 4. Nothing happens, but the error message should be displayed; Returning to the field and typing some letters. 6. Focusing; 7. Come back to the field; 8. Clearing the area. 9. The error field is displayed even before leaving the field.

HTML code:

  & lt ;! DOCTYPE html public "- // W3C // DTD XHTML 1.0 Transcription / / n" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> & Lt; Html xmlns = "http://www.w3.org/1999/xhtml" & gt; & Lt; Top & gt; & Lt; Script src = "web / script / jquery-1.3.2.min.js" type = "text / javascript" & gt; & Lt; / Script & gt; & Lt; Script src = "web / script / jquery.validate.js" type = "text / javascript" & gt; & Lt; / Script & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Form id = "form1" & gt; & Lt; Input type = "text" id = "name1" name = "name1" value = "test" /> gt; & Lt; Br / & gt; & Lt; Input type = "text" / & gt; & Lt; / Form & gt; & Lt; Script type = "text / javascript" & gt; Validate ({Rule: {name1: {Required: true, minlength: 2}}, Message: {name1: "bad name"), $ {document} .ready (function () {var validator = $ ("form" }}};});    

You can override the onfocusout handler to work as you want (more curious):

  $ (function () {var validator = $ ("form"). , Onfocusout: function (element) {$ (element) .valid ();}});});  

See you more.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -