Skip to main content

Bug Tracker

Side navigation

#2206 closed bug (fixed)

Opened January 21, 2008 11:24PM UTC

Closed January 22, 2008 02:34AM UTC

[validate] No white space validation method not working

Reported by: ericw Owned by:
Priority: minor Milestone:
Component: plugin Version:
Keywords: validate Cc: eric@soundcloud.com
Blocked by: Blocking:
Description

when adding the standard "no white space" method to a field, the field will be marked as invalid when entering a white space, but when removing the white space the field does not get re-validated again (or at least fails to return to a valid state).

      $.validator.addMethod("nowhitespace", function(value, element) {
      	return this.optional(element) || /^S+$/i.test(value);
      }, "No white space please"); 

      $('#myform').validate({
        rules: {
          field: {
            nowhitespace: true
          }
}});

Attachments (0)
Change History (1)

Changed January 22, 2008 02:34AM UTC by scott.gonzal comment:1

resolution: → fixed
status: newclosed

A bunch of the regular expressions in additional-methods.js were not escaped properly. This file has been updated. To add the nowhitespace method properly, use:

$.validator.addMethod("nowhitespace", function(value, element) {
    return this.optional(element) || /^\\S+$/i.test(value);
}, "No white space please");