Hi all. I am struggling as to why the following code is not working. If anything after Entered M phone does not work. Could someone please fix this code for me?


Hi all. I am struggling as to why the following code is not working. If anything after Entered M phone does not work. Could someone please fix this code for me?

function validateForm() { var FName_check = document.forms["form1"]["FirstName"].value; if (FName_check =="") { alert("A first name must be entered!"); return false;

} var SName_check = document.forms["form1"]["Surname"].value; if (SName_check =="") { alert("A Surname must be entered!"); return false; } var Comments_check = document.forms["form1"]["Comments"].value; if (Comments_check =="") { alert("Please leave a comment!"); return false; } var EnteredMPhone = document.getElementById("PhoneNum").value; if (EnteredMPhone =="") { alert("You must enter a home phone number!"); return false; } var MobCheck = /^0[4][0-9]{2} ?[0-9]{3} ?[0-9]{3}$/; if (EnteredMPhone.match(MobCheck)) {return (true);} { alert("The mobile phone number you have entered " + EnteredMPhone + " does not have the expected format eg '0417 525 954'."); return false; 

}; var EnteredHPhone = document.getElementById("HomePhone").value;

 if (EnteredHPhone =="") { alert("You must enter a home phone number!"); return false; } var HomeCheck = /^0[2-8] ?[0-9]{4} ?[0-9]{4}$/; if (EnteredHPhone.match(HomeCheck)) {return true;} { alert("The home phone number you have entered " + EnteredHPhone + " does not have the expected format eg '03 5332 6719'."); return false;} 

}

Submitted August 14, 2017 at 08:35AM by C_an
via reddit http://ift.tt/2fDz8qV

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s