Created
October 23, 2012 19:12
-
-
Save rfessler/3940947 to your computer and use it in GitHub Desktop.
javascript: jquery: Validate on Blur - jQuery Validate on Blur
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form name="myForm"> | |
<fieldset> | |
<legend>My Form</legend> | |
First Name: <input class="required" type="text" id="firstName" name="firstName"> * required<br> | |
Last Name: <input class="required" type="text" id="lastName" name="lastName"> * required | |
</fieldset> | |
<input type="submit"> | |
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var v = $("form").validate({ | |
submitHandler: function() { | |
console.log('successful submit'); | |
return false; | |
} | |
}); | |
$('#firstName').blur(function(){ | |
v.element('#firstName'); | |
}); | |
$('#lastName').blur(function(){ | |
v.element('#lastName'); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.error { color: red; } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment