Bug Tracker

Modify

Ticket #2206 (closed bug: fixed)

Opened 5 years ago

Last modified 5 years ago

[validate] No white space validation method not working

Reported by: ericw Owned by:
Priority: minor Milestone:
Component: plugin Version:
Keywords: validate Cc: eric@…
Blocking: Blocked by:

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

comment:1 Changed 5 years ago by scott.gonzal

  • Status changed from new to closed
  • Resolution set to fixed

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");

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.