Jump to content

Need Help!


tally79

Recommended Posts

Okay, I'm not very good at programming language but I do understand the basics. I am trying to create a form validation using Javascript. If you have an alternative solution to form validation please share. Otherwise, below is what I have setup thus far...it works but it doesn't validate all the fields....any help is appreciated :) The Javascript I used was taken from the W3schools website on the Javascript Validation tutorial.This is the Javascript Sheet

// JavaScript Document<!--function validate_required(field,alerttxt){with (field){if (value==null||value=="")  {alert(alerttxt);return false}else {return true}}}function validatesecurity_required(field,alerttxt){with (field){if (value==null||value=="red white blue")  {return true}else {alert(alerttxt);return false}}}function validateterms_required(field,alerttxt){with (field){if (value==null||checked=="")  {alert(alerttxt);return false}else {return true}}}//--><!--function validate_form(thisform){with (thisform){if (validate_required(Full_Name,"Full Name must be filled out!")==false)  {Full_Name.focus();return false}}}function validate_form(thisform){with (thisform){if (validate_required(Area_Code,"You must provide an Area Code!")==false)  {Area_Code.focus();return false}}}function validate_form(thisform){with (thisform){if (validate_required(First_Phone,"You must provide a complete Phone Number!")==false)  {First_Phone.focus();return false}}}function validate_form(thisform){with (thisform){if (validate_required(Second_Phone,"You must provide a complete Phone Number!")==false)  {First_Phone.focus();return false}}}function validate_form(thisform){with (thisform){if (validatesecurity_required(Security_Question,"You provided the wrong answer to the Security Question. If you have any questions or continue to have problems please contact the webmaster.")==false)  {Security_Question.focus();return false}}}function validate_form(thisform){with (thisform){if (validateterms_required(Terms_Agreement,"You must agree to the Terms of Use and Privacy Policy!")==false)  {Terms_Agreement.focus();return false}}}//-->

This is the HTML Form page

		<form name="contact_form" action="http://lklp.org/v-cgi/forms.cgi" enctype="application/x-www-form-urlencoded" method="post" onSubmit="return validate_form (this);">		<fieldset>		<legend>Contact Information</legend>		<label>* Name</label>		<input type="text" name="Full_Name" size="30"/><br><br>		<label>Email</label>		<input type="text" name="Email_Address" size="30"/><br><br>		<label>* Phone</label>		<input type="text" name="Area_Code"  size="6" /> <strong><label>-</label></strong> <input type="text" name="First_Phone"  size="6" /> <strong><label>-</label></strong> <input type="text" name="Second_Phone"  size="8" /><br><br>		<label>Alternate Phone</label>		<input type="text" name="Alt_Area_Code"  size="6" /> <strong>-</strong> <input type="text" name="Alt_Phone"  size="6" /> <strong>-</strong> <input type="text" name="Alt_Phone_2"  size="8" /><br><br>		</fieldset>		<br>		<fieldset>		<legend>Where did you here about us? (Optional)</legend>		<select name="Hear_About_Us" size="1">		<option value=""></option>		<option value="Friend">Friend</option>		<option value="LKLP Representative">LKLP Representative</option>		<option value="Online Search Engine">Online Search Engine</option>		<option value="Another Organization">Another Organization</option>		<option value="Other">Other</option>		</select><br><br>		<label>If Other:</label> <input type="text" name="Other"  size="30" />		</fieldset>		<br>		<fieldset>		<legend>Comments/Questions (Optional)</legend>		<textarea name="Comments_Questions" rows="20" cols="40"></textarea>		</fieldset>		<br>		<fieldset>		<legend>Security Question *</legend>		<label>What colors are the American Flag?</label>		<br>		<span id="footnotes">(Type all three colors only, include spaces between each word, lower case letters, and NO Commas.)</span>		<br>		<input type="text" name="Security_Question"  size="30" />		</fieldset>		<br>		<div>Please Read Before You Press Submit:</div>		<div>		<p>In order to process complaints against LKLP, LKLP Employees, or anything/anyone affiliated with LKLP you must use the <a href="admin/complaintform.htm">Online Complaint Form</a>.</p>		<p>All information provided via this online contact form is not 100% secure from third party viewing; however, any information submitted to any LKLP employee via any online form will be kept strictly confidential and will not be shared with anyone. Please visit our <a href="privacy.htm" target="_blank">Privacy Policy</a> and <a href="terms.htm" target="_blank">Terms of Use</a> for more information.</p>		<p>You must agree to the Terms of Use and Privacy Policy before you press Submt.<br>		</div>		<div><input name="Terms_Agreement" type="checkbox" value="I Agree"/>		   <strong>By checking this box you agree to the <a href="terms.htm">Terms of Use</a> and <a href="privacy.htm">Privacy Policy</a>? * </strong></div>		<br><br>		<input type="submit" name="Form_Submit" value="Submit Form"/>	 		<input type="reset"  name="reset" value="Clear Form"/>		<input type="hidden" name="_vDeckformid" value="819" />		</form>

Link to comment
Share on other sites

You have multiple validate_form functions declared, you can only have one. Move all of the statements you want to be executed into the same function.You should also be aware that javascript should only be used as a convenience to the user, all of the data should also be checked on the server side. So some people consider javascript validation a waste of time, but it is more convenient for the user.

Link to comment
Share on other sites

You should also be aware that javascript should only be used as a convenience to the user, all of the data should also be checked on the server side. So some people consider javascript validation a waste of time, but it is more convenient for the user.
I don't know much programming language, what would you recommend to use for server side validation? Are there any resources to use that would be helpful for a beginner?
Link to comment
Share on other sites

Okay, if anyone wants to help that would be great but it's okay if not...this is what I need to do...I need to validate a form on the server side or javascript (but I know that javascript validation is not recommended)....the form fields will include the followingName (Required)Email Address (Not Required)Phone Number (Required)Alt Phone Number (Not Required)How did you hear about us? (Not Required)If Other: (Not Required)Comments/Questions (Required)What are the colors of the american flag? (Required)(Answer should be red white blue) -- This is to prevent a computer from automatically filling out the form and submitting it. I was also thinking about creating a gif image with letters instead of using a general question like this one.Here is the link to the form: www.lklp.org/adminform2.htmAny help would be much appreciated. Thanks!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...