HTML Code
1 2 3 4 5 6 |
<form id="myform"> <input type="text" name="field" /> <br/> <input type="submit" /> </form> <a id="docs" href="http://docs.jquery.com/Plugins/Validation" target="_blank">Validation Documentation</a> |
CSS Code
1 2 3 4 5 6 |
#docs { display: block; position: fixed; bottom: 0; right: 0; } |
Javascript Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
$(document).ready(function () { $('#myform').validate({ // initialize the plugin onkeyup: function (element, event) { if (event.which === 9 && this.elementValue(element) === "") { return; } else { this.element(element); } }, rules: { field: { required: true, minlength: 6 } }, submitHandler: function (form) { // for demo alert('valid form submitted'); // for demo return false; // for demo } }); }); |