jQuery Validator Extension: No Space


/ Published in: jQuery
Save to your folder(s)



Copy this code and paste it in your HTML
  1. $(document).ready(function()
  2. {
  3. // Add Method too jQuery Validator
  4. jQuery.validator.addMethod("noSpace", function(value, element)
  5. { return value.indexOf(" ") < 0 && value != ""; }, "No space please and don't leave it empty");
  6. // Apply to jQuery Validate rules
  7. $("form").validate({
  8. rules: {
  9. name: { noSpace: true }
  10. }
  11. });
  12. })

URL: http://stackoverflow.com/questions/2942325/jquery-form-validate-not-allow-space-for-username-field

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.