Skip to content

Commit a451672

Browse files
author
Olivier Poitrey
committed
Fix pattern validator failing on optional fields if pattern doesn't allow empty value (Fix jquerytools#605)
1 parent fc1115e commit a451672

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/validator/validator.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,8 @@
251251
return !!v;
252252
});
253253

254-
v.fn("[pattern]", function(el) {
255-
var p = new RegExp("^" + el.attr("pattern") + "$");
256-
return p.test(el.val());
254+
v.fn("[pattern]", function(el, v) {
255+
return v === '' || new RegExp("^" + el.attr("pattern") + "$").test(v);
257256
});
258257

259258

0 commit comments

Comments
 (0)