Bug Tracker

Opened 12 years ago

Closed 12 years ago

#2206 closed bug (fixed)

[validate] No white space validation method not working

Reported by: ericw Owned by:
Priority: minor Milestone:
Component: plugin Version:
Keywords: validate Cc: eric@…
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
          }
}});

Change History (1)

comment:1 Changed 12 years ago by scott.gonzal

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");
Note: See TracTickets for help on using tickets.