Posted By

mantosz on 08/01/11


Tagged

space validation no extension


Versions (?)

jQuery Validator Extension: No Space


 / Published in: jQuery
 

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

  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. })

Report this snippet  

You need to login to post a comment.