Modify ↓
Ticket #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@… |
| 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
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.
Note: See
TracTickets for help on using
tickets.

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