Created
June 30, 2013 11:36
-
-
Save LinuxPhreak/5894844 to your computer and use it in GitHub Desktop.
Everything works until the end where I try to check to see if passwords validate. Any ideas?
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
<html> | |
<head> | |
<script type="text/javascript" charset="utf-8"> | |
function validateForm() | |
{ | |
/* This is to make sure the user entered their first name */ | |
var firstname=document.forms["signuppage"]["fname"].value; | |
if (firstname==null || firstname=="") | |
{ | |
alert("First name must be filled out"); | |
return false; | |
} | |
/* This is to make sure the user entered their last name */ | |
var lastname=document.forms["signuppage"]["lname"].value; | |
if (lastname==null || lastname=="") | |
{ | |
alert("Last name must be filled out"); | |
return false; | |
} | |
/* This is to make sure the user entered a correct E-Mail Format. Note: I could not use regex /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/ | |
because it conflicts with the regex phone number */ | |
var emailx=document.forms["signuppage"]["email"].value; | |
var emaily=document.forms["signuppage"]["remail"].value; | |
var atpos=emailx.indexOf("@"); | |
var dotpos=emailx.lastIndexOf("."); | |
if (atpos<1 || dotpos<atpos+2 || dotpos+2>=emailx.length) | |
{ | |
alert("Not a valid e-mail address"); | |
return false; | |
} | |
if (emailx != emaily) | |
{ | |
alert("E-Mail Fields don't match"); | |
return false; | |
} | |
/* This is to validate the phone number */ | |
var phoneno = /^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$/; | |
if (document.forms["signuppage"]["phone"].value.match(phoneno)) | |
{ | |
return true; | |
} | |
else | |
{ | |
alert("Not A Valid Phone Number"); | |
return false; | |
} | |
/* Code Breaks here */ | |
var passx=document.forms["signuppage"]["pw"].value; | |
var passy=document.forms["signuppage"]["repw"].value; | |
if (passx != passy) | |
{ | |
alert("Password Fields don't match"); | |
return false; | |
} | |
} | |
</script> | |
</head> | |
<body> | |
<form name="signuppage" action="account-create.php" onsubmit="return validateForm()" method="post"> | |
<label for="fname">First Name:</label> | |
<input type="text" name="fname" placeholder="John"> | |
<label for="lname">Last Name:</label> | |
<input type="text" name="lname" placeholder="Doe"> | |
<label for="email">E-Mail:</label> | |
<input type="text" name="email" placeholder="youremail@domain.com"> | |
<label for="remail">Retype E-Mail:</label> | |
<input type="text" name="remail" placeholder="youremail@domain.com"> | |
<label for="phone">Phone Number:</label> | |
<input type="text" name="phone" placeholder="555-555-1212"> | |
<label for="age">Your Age:</label> | |
<input type="text" name="age" placeholder="30"> | |
<label for="pw">Password</label> | |
<input type="text" name="pw" /> | |
<label for="repw">Retype Password:</label> | |
<input type="text" name="repw" /> | |
<input type="submit" value="Submit" /> | |
</form> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment