I'm trying to filter out date results, but I think I may have the regular expression wrong.
if ((strSearchInx == 6) || (strSearchInx == 7)) {
var regDate = new RegExp("/^\d{1,2}\/\d{1,2}\/\d{4}$/");
strSearchField = strSearchField.trim();
//alert(strSearchField);
if (regDate.test(strSearchField) == false) {
alert("Date does not match mm/dd/yyyy format. Please re-enter");
document.getElementById('searchfield').focus();
return false;
}
}
I've tested it against 8/3/2016 and it doesn't seem to let any response through: Is /^\d{1,2}/\d{1,2}/\d{4}$/ the correct regular expression?
Thanks.