Permalink
Browse files

Fix pattern validator failing on optional fields if pattern doesn't a…

…llow empty value (Fix #605)
  • Loading branch information...
1 parent fc1115e commit a451672750137c8c65893d105524dc8bd99360dc @rs rs committed Dec 28, 2011
Showing with 2 additions and 3 deletions.
  1. +2 −3 src/validator/validator.js
View
5 src/validator/validator.js
@@ -251,9 +251,8 @@
return !!v;
});
- v.fn("[pattern]", function(el) {
- var p = new RegExp("^" + el.attr("pattern") + "$");
- return p.test(el.val());
+ v.fn("[pattern]", function(el, v) {
+ return v === '' || new RegExp("^" + el.attr("pattern") + "$").test(v);
});

0 comments on commit a451672

Please sign in to comment.