Skip to content

Commit

Permalink
additional/pattern.js: Don't use exec() or test() here
Browse files Browse the repository at this point in the history
In some cases, this code will not work correctly. Calling these methods on the same RegExp, will start checking from the end of the previous comparison.
  • Loading branch information
Stas B committed Aug 13, 2018
1 parent 47e0d92 commit cdd54e8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/additional/pattern.js
Expand Up @@ -18,5 +18,5 @@ $.validator.addMethod( "pattern", function( value, element, param ) {
if ( typeof param === "string" ) {
param = new RegExp( "^(?:" + param + ")$" );
}
return param.test( value );
return value.match( param ) !== null;
}, "Invalid format." );

0 comments on commit cdd54e8

Please sign in to comment.