HTML - Form Validation Help Needed Please
I have a form that i want to ensure is filled out correctly before the user is able to proceed.
http://chimp.cc/start.htm If the user fails to fill out the terms and conditions box with a "Yes"when the user clicks submit, i want a message to pop up to tell them to complete it. and to return the user to that field for completion. I honestly have no idea how to do this, can someone please help me. I have attached the source code too. Cheers Andy Similar TutorialsHi, I am new to html, i have a form that i needed to add a line, but when i try to do it in Dreamweaver, the other co-ordinates are getting shifted. If anybody can give me pointers, i'll really appreciate it. Thanks, Wondering if anyone can help me out or point me in the right direction... I am looking at setting up a radio form that will populate with mandatory fields that must be filled out before sending it off. I am restricted to using HTML only and maybe some JavaScript.. I have attached my idea in image on this post and could really use some assistance in finding a solution for this I need to correct some code for an email link. It's complicated and I need help offline. I'm willing to pay decent money for the help. It involves a secured email form. Please email me at helpline1958@yahoo.com <form name="form1" method="POST" action="finance_request.shtml" webbot-action="--WEBBOT-SELF--"> <!--webbot bot="SaveResults" S-Email-Format="TEXT/PRE" S-Email-Address=" ....... Thanks Hello, I'm creating an HTML form. The Submit button is not working - when I press the Submit button, the browser opens a new tab and logs into my Yahoo account. It has never done this before. I'm using IE 9. PLEASE HELP! I'm baffled. Here's the html tags for the form: <form name="guestbook" action="mailto:kjohnson@calbaptist.edu" method="post"> <p><b>First Name:</b> <input type="text" name="fname" size="25" /></p> <p><b>Last Name:</b> <input type="text" name="lname" size="35" /> </p> <p><b>Age level:</b></p> <input name="1" type="radio" value="under18" />Under 18<br/> <input name="1" type="radio" value="18-30" />18-30<br/> <input name="1" type="radio" value="31-45" />31-45<br/> <input name="1" type="radio" value="over45" />Over 45</br> <p><b>Interests (Check all that apply):</b></p> <input type="checkbox" name="sports" />Sports<br/> <input type="checkbox" name="music" />Music<br/> <input type="checkbox" name="crafts" />Crafts<br/> <p><b>Grade Status:</b></p> <select name="gradestatus"> <option> Click on your status</option> <option> High School Student</option> <option> Undergraduate Student</option> <option> Graduate Student </select> <p><b>Comments:</b></p> <textarea name="comments" rows=5 cols=50></textarea> <br /><br /> <input type="submit" name="submit" value="Submit" /> <input type="reset" name="reset" value="Reset" /> </form> Hi, Below is my line of input code where I pass a certain variable. What I want to know is - is it possible to leave that 'identifer' value out of the url string if a user does not enter anything in that field? It's for a hotel reservation system and if left blank, it causes an error. It works fine is a user enters a code though. Code: <input type="text" name="identifier" value="" style="width:70px; font-size:11px;" /> Any ideas? Thanks firstly hello to everyone - sorry for not introducing myself prior to posting but im in DESPERATE need of help and hope someone will take pity on me and put me out my misery!!! I am trying to include an order form in a website i am building.. i would like it to have the ability to 'copy' information from 'customers details' to 'delivery details' if these are one and the same - i have tried various things all to no avail... here is what i have so far.... -------------------------------------------------------------------------------------------------------- <HTML> <head> <title></title> <script type="text/javascript"> function data_copy() { if(document.form1.copy[0].checked){ document.form1."Delivery Name".value=document.form1."Customer Name".value; document.form1."Delivery Address 1".value=document.form1."Customer Address 1".value; document.form1."Delivery Address 2".value=document.form1."Customer Address 2".value; document.form1."Delivery Town".value=document.form1."Customer Town".value; document.form1."Delivery County".value=document.form1."Customer County".value; document.form1."Delivery Post Code".value=document.form1."Customer Post Code".value; }else{ document.form1."Delivery Name".value=""; document.form1."Delivery Address 1".value=""; document.form1."Delivery Address 2".value=""; document.form1."Delivery Town".value=""; document.form1."Delivery County".value=""; document.form1."Delivery Post Code".value=""; } } </script> </head> <form name=form1 action=""> <TABLE width="800" border="0" align="center" cellpadding="5" cellspacing="0"> <tr bgcolor="#FFFFFF"> <td width="300" align="left"><font size="2" face="Verdana"><b>Customer Details:</b></font></td> <td width="200"></td> <td width="200"></td> <td width="300" align="left"><font size="2" face="Verdana"><b>Delivery Details:</b></font></td> <td width="200"></td> </tr> <tr> <td></td> <td></td> <td></td> <td><input type=radio name=copy value='yes' onclick="data_copy()";><font face="Verdana" size="2">Same As Customer</font></td> <td><input type=radio name=copy value='no' onclick="data_copy()";><font face="Verdana" size="2">Not Same</font></td> </tr> <tr bgcolor="#FFFFFF"> <td width="300" align="left"><font size="2" face="Verdana">Name:</font></td> <td width="200" align="left"><input name="Customer Name" type="text" size="30"></td> <td width="200"></td> <td width="300" align="left"><font size="2" face="Verdana">Name:</font></td> <td width="200" align="left"><input name="Delivery Name" type="text" size="30"></td> </tr> <tr bgcolor="#FFFFFF"> <td width="300" align="left"><font size="2" face="Verdana">Address 1:</font></td> <td width="200" align="left"><input name="Customer Address 1" type="text" size="30"></td> <td width="200"></td> <td width="300" align="left"><font size="2" face="Verdana">Address 1:</font></td> <td width="200" align="left"><input name="Delivery Address 1" type="text" size="30"></td> </tr> <tr bgcolor="#FFFFFF"> <td width="300" align="left"><font size="2" face="Verdana">Address 2:</font></td> <td width="200" align="left"><input name="Customer Address 2" type="text" size="30"></td> <td width="200"></td> <td width="300" align="left"><font size="2" face="Verdana">Address 2:</font></td> <td width="200" align="left"><input name="Delivery Address 2" type="text" size="30"></td> </tr> <tr bgcolor="#FFFFFF"> <td width="300" align="left"><font size="2" face="Verdana">Town:</font></td> <td width="200" align="left"><input name="Customer Town" type="text" size="30"></td> <td width="200"></td> <td width="300" align="left"><font size="2" face="Verdana">Town:</font></td> <td width="200" align="left"><input name="Delivery Town" type="text" size="30"></td> </tr> <tr bgcolor="#FFFFFF"> <td width="300" align="left"><font size="2" face="Verdana">County:</font></td> <td width="200" align="left"><input name="Customer County" type="text" size="30"></td> <td width="200"></td> <td width="300" align="left"><font size="2" face="Verdana">County:</font></td> <td width="200" align="left"><input name="Delivery County" type="text" size="30"></td> </tr> <tr bgcolor="#FFFFFF"> <td width="300" align="left"><font size="2" face="Verdana">Post Code:</font></td> <td width="200" align="left"><input name="Customer Post Code" type="text" size="15"></td> <td width="200"></td> <td width="300" align="left"><font size="2" face="Verdana">Post Code:</font></td> <td width="200" align="left"><input name="Delivery Post Code" type="text" size="15"></td> </tr> </table><br> <br><input type="Submit"> </form> </body> -------------------------------------------------------------------------------------------------------- although it looks ok when i preview it for some reason it will not copy the information i want... if anyone can help (and ideally explain what i am doing wrong) i would be very very thankful! kind regards lawrence (larryg) When trying to validate more then one text box, the code ignores the first set of code and moves straight to the second :\ why does it do that? HTML Code: <script type="text/javascript"> <!-- function validate_form ( ) { valid = true; if ( document.MyFrom.fname.value == "" ) { alert ( "Please fill in the 'Your Name' box." ); valid = false; } return valid; } function validate_form ( ) { valid = true; if ( document.MyFrom.lname.value == "" ) { alert ( "Please fill in the 'Youlr Name' box." ); valid = false; } return valid; } </script> Hi I am using a CGI-BIN script to submit an html form to an email address. I am wondering how i can make field in this html form "required"?? Would be thankful if someone could point me in the right direction. Hi everyone, does anyone know how to make it so, on a form, when a person inputs their phone number it wont accept anything less than 11 numbers and anything more than 11 numbers? Thanks Could someone please advise how to make a singular field validated before sending via smtp, through a Content Management system. I do not have access to the CSS side of things and am hoping this will help my own knowledge banks. The RTE does accept some types of Javascrpt but a resolution in this would ahve to be very simple. Appreciated any help given, thanks all. Tom Hi guys i have a form that has name , email , country (drop down list ) , state , city , address , phone . I would like to validate the form so that when a space is left empty for example the "name" space is left empty a message box alerts them Hi, I'm new to the forums, so if this is in the wrong place i apologize. I've been thrown into the fire at work to develop some of the website and I'm absolutely stuck on one of my forms. It's submitting name, email and a couple checkboxes. I need the script to verify that the fields are not blank, the email field is a valid address, and the checkboxes are checked. Any ideas? <body> <script> function Do_it() { if(document.Form1.FirstName.value == "") { errormessage += "\n\nPlease fill out your first name."; } if(document.Form1.LastName.value == "") { errormessage += "\n\nPlease fill out your last name."; } if(document.Form1.email.value == "") { errormessage += "\n\nPlease fill out your email address."; } if(document.Form1.checkbox1.value == "") { errormessage += "\n\nPlease verify you are 13 or older."; } if(document.Form1.checkbox2.value == "") { errormessage += "\n\nPlease verify you have read and agree to the Privacy Policy."; } } return false; else return true; } </script> <div id="Layer1"> <div align="center"><img src="bg.jpg" width="800" height="600" /> </div> <div id="Layer13"> <form action="feedback.php" method="post" name="Form1" onSubmit="return Do_it()"> <table width="100%" height="100%" border="0" cellpadding="5" cellspacing="2" style="width: 445px; height: 100%;"> <tr> <td nowrap="nowrap"><div align="right"> First Name:</div></td> <td><input class="dsR2" type="text" name="FirstName" size="43" /></td> </tr> <tr> <td nowrap="nowrap"><div align="right"> Last Name:</div></td> <td><input class="dsR3" type="text" name="LastName" size="43" /></td> </tr> <tr> <td nowrap="nowrap"><div align="right"> E-mail:</div></td> <td><input class="dsR4" type="text" name="email" size="43" /></td> </tr> <tr> <td nowrap="nowrap"><div align="right"> <input class="dsR1" type="checkbox" name="checkbox1" /> </div></td> <td> I am over 13 years of age. </td> </tr> <tr> <td nowrap="nowrap"><div align="right"> <input class="dsR1" type="checkbox" name="checkbox2" /> </div></td> <td>I read and agree to the <a href="terms.html" target="_blank">Privacy Policy </a></td> </tr> <tr> <td colspan="2" nowrap="nowrap"><div align="center"> <p> <input name="submit" type="submit" class="dsR1" value="Submit" /> </p> </div></td> </tr> <tr> <td colspan="2" valign="top"><div align="center"><span class="style1"> </span> <div id="Layer3"> <div align="center"><span class="style2">We respect your privacy and understand the value of protecting personally identifiable information, we pledge not to sell any personally identifiable information to any third party</span>.</div> </div> </div></td> </tr> </table> </form> </div> </body> If you look here at http://www.babyjai.com/quote.php you will see the form validates before it tries to push it thru, how come when you look at http://dinasky.me/contact.php it doesnt do it, it just pushed it thru, i cannot figure it out! Hello, I have an trouble with an html form validation called in a div with a javascript code for form validation. I have a main page in which I have a named div(workplace) where I call a html form page. Once the form page is called in the "workplace" div, the form is working, I can submit the entries to the database but the javascript validation doesn't work. But if I open the form in a decicated browser window then the javascript form validation works. I want to use div because everywhere I'm reading that "frames" is the devil and I should use div tag instead. Where could be my trouble? Your help is appreciated. Below there are my main page & form page. Main page html code Code: <html> <head> <script type="text/javascript" src="../library/ajax_navagation.js"></script> <title>My Web page</title> </head> <body> <div id="Menu"> <p><a href="javascript:void(0)" onClick="open_url('../admin/adduser.html', 'workplace');">Add user</a></p> <p><a href="javascript:void(0)" onClick="open_url('../admin/showusers.php', 'workplace');">Show users</a></p> </div> <div id="workplace"></div> </body> </html> Add user form with javascript for form validation Code: <script type="text/javascript"> <!-- function MM_validateForm() { //v4.0 if (document.getElementById){ var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments; for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]); if (val) { nm=val.name; if ((val=val.value)!="") { if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@'); if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n'; } else if (test!='R') { num = parseFloat(val); if (isNaN(val)) errors+='- '+nm+' must contain a number.\n'; if (test.indexOf('inRange') != -1) { p=test.indexOf(':'); min=test.substring(8,p); max=test.substring(p+1); if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n'; } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; } } if (errors) alert('The following error(s) occurred:\n'+errors); document.MM_returnValue = (errors == ''); } } //--> </script> Add new user <form action="../ui/admin/adduser.php" method="post" name=adduser onSubmit="MM_validateForm('username','','R','password','','R',);return document.MM_returnValue"> <table width="400" border="0" cellspacing="1" cellpadding="2"> <tr> <td width="100">Username</td> <td><input name="username" type="text" id="username"> *</td> </tr> <tr> <td width="100">Password</td> <td><input name="password" type="text" id="password"> *</td> <tr> <td width="100"> </td> <td> </td> </tr> <tr> <td width="100"> </td> <td><input name="add" type="submit" id="add" value="Add New User" ></td> </tr> </table> </form> <form class="contact" method="post" action="mail.php#contact" /> Hi I realy need help with my coursework! I am really bad with HTML and forms I want my form to not send to the email address i have specified unless all the fields in the form are full, this wont be a problem with the select boxes and the radio buttons as they are already selected. I only need to validate the text field and area. This is my form so far ... Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> <style type="text/css"> <!-- body,td,th { font-family: Arial, Helvetica, sans-serif; } .style1 {color: #FFFFFF} .style2 {font-size: 14px} --> </style> <form action="script.cgi" onSubmit="return checkform()"> <script> function checkform() { if (value of textfield is null) { alert('Please insert your name'); return false; } else if(value of textarea is null) { alert('Please enter your comments for this website'); return false; } return true; } </head> <body> <form action="emailformhandler.php" method="post" name="Feedback Form" class="style2" id="Feedback Form"> <p align="left">Your Name <span class="style1"> .................................................</span> <input type="text" name="textfield" size="30" maxlength="100" /> </p> <p>Where do you live? <span class="style1">....................................</span> <select name="select" size="1"> <option>Dunstable</option> <option>Luton</option> <option>Houghton Regis</option> <option>Other</option> </select> </p> <p>How did you find out about this website? <span class="style1">....</span> <select name="select2" size="1"> <option>Your Teacher</option> <option>Mr Holmes</option> <option>Word Of Mouth</option> <option>SSCO</option> <option>Search Engine</option> <option>Other</option> </select> </p> <p><img src="http://himeshs.co.uk/ICT/untitled.GIF" width="181" height="56" /><span class="style1">.......................</span> <textarea name="textarea" cols="30" rows="5"></textarea> </p> <p> What is your rating of this website <span class="style1">.............</span> <input name="radiobutton" type="radio" value="radiobutton" checked /> Excellent <input name="radiobutton" type="radio" value="radiobutton" /> Good <input name="radiobutton" type="radio" value="radiobutton" /> Average <input name="radiobutton" type="radio" value="radiobutton" /> Poor</p> <p> <input type="submit" name="Submit" value="Submit Form" /> <input type="reset" name="Submit2" value="Clear Form" /> </p> </form> </body> </html> I would appreciate any help i could get and dont forget im a noob at forms nd stuff like that lol Thanks! Himesh I'm using Godaddy's gdform.php form mailer for my forms. The forms work perfectly except the validation. I need the visitors to fill in the fields and then submit the information to my email, but the problem is that everyone can submitt even if he doesn't fill in the form. I want all of the fileds to be required. Is there something wrong with the code ? Here it is : <form action="/gdform.php" method="post"> <table align="center"> <input type="hidden" name="subject" value="Form Submission"> <input type="hidden" name="redirect" value="/Add/thankmes.html"> <input type="hidden" name="required" value="YourName, Email, description"> <tr> <td><p><font color=WHITE font size=4>Your Name:</p> </font></td> <td align=center height=50><p><input type="text" name="YourName" size="52"/></p></td> </tr> <tr> <td><p><font color=WHITE font size=4>Your E-mail:</p> </font></td> <td height=50><p><input type="text" name="Email" size="52"/></p></td> </tr> <tr> <td><p><font color=WHITE font size=4>Your Message:</p> </font></td> <td><br><p><textarea name="description" cols="40" rows="5"> </textarea></p></td> </tr> <tr> <td><input type="submit" name="submit" value="Send"/></td> </tr> </table> </form> have a form.. has certain input fileds like - sptn, rptn, mps, mpr etc am trying to validate all entries to be entirely numeric and within range if (sptn>0 && sptn<65535 && rp>0 && rp<65535 && rptn>0 && rptn<65535 && mps>0 && mps<65535 && mpr>0 && mpr<65535) alert("all values ok"); problem is => this works even if i enter any of the values as =-=-=- or ./,/.,-= or any other junk characters but this snippet works fine if (spn>99 && spn<=999 && rpn>99 && rpn<=999) alert("ok"); please advise Hi Ya, I am trying to validate the telephone number for a form. I would really like some help. You see when i leave the telephone field blank the code error message comes up telling me that i cant leave that field blank. When i then put in illegal characters it says that i used illegal characters but instead of clearing the feild,allowing me to type the correct phone number and then moving onto the getradio if statement it goes to receipt page when the submit button is clicked instead of doing the validate checks first and then moving onto the receipt.html page. This is the problem area. Code: if (form.phone.value == "") { alert("Please enter your telephone number for shipping Information."); form.phone.focus(); return (false); } else { validate(); } if (getRadio("pay") == null) { alert("Please choose a payment method."); return (false); } return (true); } //--></script> <script language="javascript"> function validate() { if (isNaN(parseInt(this.value))) { alert("The phone number contains illegal characters."); form.phone.focus(); return (false); } } //--></script> The below code is for the form. Code: <FORM name="information" action="..\..\Cars\GT\receipt.html" method="get" onSubmit=" return form_Validator(this)"> <!-- Tells the button what action to take --> The below code is the full validation check function Code: <!-- This is used to validate the radio buttons to make sure that one of those options are pressed --> <script language="javascript"> function getRadio(radioName){ var inputs = document.getElementsByTagName('input'); var ret = null; for(var i = 0; i < inputs.length; i++){ if(inputs[i].type == 'radio' && (inputs[i].name == radioName || inputs[i].id == radioName) && inputs[i].checked){ ret = inputs[i].value; } } return ret; } <!-- This is used to validate the text boxes to make sure that an item is written into it --> <!-- I f the next box remains empty an error message appears --> function form_Validator(form) { if (form.first_name.value == "") { alert("Please enter your first name for shipping Information."); form.first_name.focus(); return (false); } if (form.last_name.value == "") { alert("Please enter your last name for shipping Information."); form.last_name.focus(); return (false); } if (form.address.value == "") { alert("Please enter your address for shipping Information."); form.address.focus(); return (false); } if (form.acode.value == "") { alert("Please enter the area code for shipping Information."); form.acode.focus(); return (false); } if (form.phone.value == "") { alert("Please enter your telephone number for shipping Information."); form.phone.focus(); return (false); } else { validate(); } if (getRadio("pay") == null) { alert("Please choose a payment method."); return (false); } return (true); } //--></script> <script language="javascript"> function validate() { if (isNaN(parseInt(this.value))) { alert("The phone number contains illegal characters."); form.phone.focus(); return (false); } } //--></script> </head> |