darthmikeyd Posted August 19, 2012 Share Posted August 19, 2012 I have some javascript that is for some reason not running. I am not getting an error, it is just not running the code. This was working the other day, and I don't think anything has changed. Let me show you my code, and if anyone has any ideas, that would be great. Code to include the javascript file (this is in the heading tag): <script language="javascript" type="text/javascript" src="taverntainment.js"></script> The form calling the javascript: <form name="frmRegister" action="saveplayerreg.php" onsubmit="return validate_form(this)" method="post"> <table align="center"> <tr> <td colspan="2"><h1 align="center" class="style1">Player Registration</h1></td> </tr> <tr> <td align="right"><font size="+1" class="style1"><b>First Name:</font></b></td><td align="left"><input type="text" name="txtFirst" placeholder="First Name" /></td> </tr> <tr> <td align="right"><font size="+1" class="style1"><b>Last Name:</font></b></td><td align="left"><input type="text" name="txtLast" placeholder="Last Name" /></td> </tr> <tr> <td align="right"><font size="+1" class="style1"><b>Email = Login Id:</font></b></td><td align="left"><input type="text" name="txtEmail" placeholder="Email" /></td> </tr> <tr> <td align="right"><font size="+1" class="style1"><b>Confirm Email:</font></b></td><td align="left"><input type="text" name="txtEmailConfirm" placeholder="Confirm Email" /></td> </tr> <tr> <td align="right"><font size="+1" class="style1"><b>City:</font></b></td><td align="left"><input type="text" name="txtCity" placeholder="City" /></td> </tr> <tr> <td align="right"><font size="+1" class="style1"><b>State:</font></b></td><td align="left"><input type="text" name="txtState" placeholder="State" /></td> </tr> <tr> <td align="right"><font size="+1" class="style1"><b>Zip Code:</font></b></td><td align="left"><input type="text" name="txtZip" placeholder="Zip Code" /></td> </tr> <tr> <td align="right"><font size="+1" class="style1"><b>Password:</font></b></td><td align="left"><input type="password" name="txtPassword" placeholder="Password" /></td> </tr> <tr> <td align="right"><font size="+1" class="style1"><b>Confirm Password:</font></b></td><td align="left"><input type="password" name="txtPassConfirm" placeholder="Confirm Password" /></td> </tr> <tr> <td colspan="2" align="center"><input type="submit" value="Register" /></td> </tr> </table> </form> And finally, my javascript code: //This function confirms the form fields are all filled correctly out for player registration function validate_form(frmRegister) { with (frmRegister) { if (validate_required(txtFirst,"First Name field must be filled out.")==false) {txtFirst.focus();return false;} if (validate_required(txtLast,"Last Name field must be filled out.")==false) {txtLast.focus();return false;} if (validate_required(txtEmail,"Email field must be filled out.")==false) {txtEmail.focus();return false;} if (validate_email(txtEmail,"Not a valid e-mail address!")==false) {txtEmail.focus();return false;} if (validate_email(txtEmailConfirm,"Not a valid e-mail address!")==false) {txtEmailConfirm.focus();return false;} if (validate_required(txtEmailConfirm,"Confirmation Email field must be filled out.")==false) {txtEmailConfirm.focus();return false;} if (validate_confirmemail(txtEmail,txtEmailConfirm,"Confirmation Email Address doesn't match Email Address entered")==false) {txtEmailConfirm.focus();return false;} if (validate_required(txtCity,"City field must be filled out.")==false) {txtCity.focus();return false;} if (validate_required(txtState,"State field must be filled out.")==false) {txtState.focus();return false;} if (validate_required(txtZip,"Zip Code field must be filled out.")==false) {txtZip.focus();return false;} if (validate_required(txtPassword,"Password field must be filled out!")==false) {txtPassword.focus();return false;} if (validate_required(txtPassConfirm,"Confirm Password field must be filled out!")==false) {txtPassConfirm.focus();return false;} if (validate_password(txtPassword,txtPassConfirm,"Confirmation Password doesn't match Password entered")==false) {txtPassConfirm.focus();return false;} } } //this function makes sure the fields aren't blank function validate_required(textbox,alerttxt) { with (textbox) { if (value==null||value=="") { alert(alerttxt);return false; } else { return true; } } } //this function confirms valid emails are entered function validate_email(field,alerttxt) { with (field) { apos=value.indexOf("@"); dotpos=value.lastIndexOf("."); if (apos<1||dotpos-apos<2) {alert(alerttxt);return false;} else {return true;} } } function validate_email_login { if (validate_email_login_test(txtEmail,"Not a valid e-mail address!")==false) {txtEmail.focus();return false;} } //this function confirms valid emails are entered function validate_email_login_test(field,alerttxt) { with (field) { apos=value.indexOf("@"); dotpos=value.lastIndexOf("."); if (apos<1||dotpos-apos<2) {alert(alerttxt);return false;} else {return true;} } } //this function confirms the email fields match function validate_confirmemail(field1,field2,alerttxt) { if (field1.value==field2.value) {return true;} else{alert(alerttxt);return false;} } //this function confirms the password fields match function validate_password(field1,field2,alerttxt) { if (field1.value==field2.value) {return true;} else{alert(alerttxt);return false;} } Any help would be great. I have no idea what is going on. Thanks Mike Quote Link to comment https://forums.phpfreaks.com/topic/267311-javascript-not-running/ Share on other sites More sharing options...
darthmikeyd Posted August 19, 2012 Author Share Posted August 19, 2012 Nevermind, it is working now. Quote Link to comment https://forums.phpfreaks.com/topic/267311-javascript-not-running/#findComment-1370727 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.