Hi everyone, ?
I’ve got the code below so far, and I just cannot figure out what’s wrong with it. I’m trying to use a RegExp (alphaNumeric) to validate the postcode field of my form. I think I’m going the correct way about it, but just not getting there somehow?
Any help on this matter would be greatly appreciated!
Kind regards,
Amph. ?
[code]
function validateFormFields()
{
alphaNumberic = /^[a-zA-Z0-9]+$/;
validateEmail = /^w+([.-]?w+)*@w+([.-]?w+)*.(w{2}|(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum))$/
valid = true;
if (document.frmCreateAcc.firstname.value == “”)
{
alert(“Please enter your first name.”);
valid = false;
document.forms[0].firstname.focus()
return false;
}
if (document.frmCreateAcc.lastname.value == “”)
{
alert(“Please enter your last name.”);
valid = false;
document.forms[0].lastname.focus()
return false;
}
if (validateEmail.test(document.frmCreateAcc.email.value) == false)
{
alert(“Please enter a valid email address”);
valid = false;
document.forms[0].email.focus()
return false;
}
if (alphaNumberic.match(document.frmCreateAcc.postcode.value) == false)
{
alert(“Please enter a valid post code.”);
valid = false;
document.forms[0].postcode.focus()
return false;
}
else
confirm(“Thank you for creating an O2 account.”);
return valid;
}