/ Published in: jQuery
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
$(document).ready(function() { // Add Method too jQuery Validator jQuery.validator.addMethod("noSpace", function(value, element) { return value.indexOf(" ") < 0 && value != ""; }, "No space please and don't leave it empty"); // Apply to jQuery Validate rules $("form").validate({ rules: { name: { noSpace: true } } }); })
URL: http://stackoverflow.com/questions/2942325/jquery-form-validate-not-allow-space-for-username-field