Created
August 23, 2013 19:56
-
-
Save QuestionDevelopment/6323334 to your computer and use it in GitHub Desktop.
allow for form validation without leaving page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script language="JavaScript" type="text/javascript"> | |
<!-- | |
function CheckForm() { | |
if (!(document.contactForm.name.value.length > 0)) | |
{ | |
alert("You must enter your Name"); | |
contactForm.name.focus(); | |
return false; | |
} | |
if (!(document.contactForm.email.value.length > 0)) | |
{ | |
alert("You must enter your Email Address"); | |
contactForm.email.focus(); | |
return false; | |
} | |
if (!(document.contactForm.phone.value.length > 0)) | |
{ | |
alert("You must enter your Phone Number"); | |
contactForm.phone.focus(); | |
return false; | |
} | |
if (document.contactForm.security.value != 'white') | |
{ | |
alert("Your Security code is incorrect"); | |
contactForm.security.focus(); | |
return false; | |
} | |
return true; | |
} | |
//--> | |
</script> | |
<form action="/contact.htm" method="post" enctype="multipart/form-data" name="contactForm" id="contactForm" onSubmit="return CheckForm();"> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment