Hello I have a question with javascript form validation and regular expressions. Below is the code I used. I am trying to validate that an address has a number and a letter from the alphabet. This code is for experimentation and does not need to do any ultra secure validation.
Problem is the below code doesn't seem to work. No matter what I do the alert box tells me I have to enter a valid address. What is wrong. Isn't the regular expression searching the value and finding false? Even if I enter a normal address like 123 Sky Rd. it still outputs Please enter a valid address.
I hope my question is clear. Below is the code to really clarify what is going on. Why is this not valid?
if (document.customerInfo.address.value == ""){
msg += "Please enter a valid address\n";
}
else if (document.customerInfo.address.value.match(/[0-9]/) != true)
{msg += "Please enter a valid address\n";}
else (document.customerInfo.address.value.match(/[abc]/) != true)
{msg += "Please enter a valid address\n";}