I am wanting to check if an input field has the attribute \"pattern\" and if so, preform a regex check aganst said pattern.I know this is already done by HTML5, but I am wan
You can try something like this. It will alert "var2 failed".
var var1 = "1";
var var2 = "A";
var myRegEx = new RegExp('[0-9]+'); //make sure the var is a number
if (var1 != myRegEx.exec(var1)) {
alert("var1 failed");
}
if (var2 != myRegEx.exec(var2)) {
alert("var2 failed");
}