Hello again,
I have a similar issue as my recent post but with a zip code validator i am trying to convert over to a javascript validation process. my script looks like so:
var regPostalCode = new RegExp("\\d{5}(-\d{4})?");
var postal_code = $("input[name='txtzipcode']").val();
if (regPostalCode.test(postal_code) == false) {
bValid = false;
msg = msg + '<li>Invalid Zip Code.</li>';
}
From my recent post i learned of the escape character that i needed at the beginning. Basically this function is validating a zip code that is say 22601 which is correct, but it shouldn't validate 22601-1. There should have to be 4 digits after the dash like 22601-9999. It's like the second part of the validation is always true. Again this expression has worked in the past for me. Am i missing something? Another escape character needed?
Thanks again, Billy