The validation is working but the form is not been submitted after the inputs have been checked.
I have been unable to find any error.
Any help will be appreciated.
Expand|Select|Wrap|Line Numbers
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <title>FORM</title>
- <script LANGUAGE="JavaScript">
- <!--
- function ValidateForm(form){
- ErrorText= "";
- if ( ( form.usage[0].checked == false ) && ( form.usage[1].checked == false )&&( form.usage[2].checked == false ) ) { alert ( "Please answer the question:Where will you be using your laptop? " ); return false; }
- if ( ( form.outside[0].checked == false ) && ( form.outside[1].checked == false ) ) { alert ( "Please answer the question:will you be using you laptop on the trains or outside at all? " ); return false; }
- if ( ( form.games[0].checked == false ) && ( form.games[1].checked == false ) ) { alert ( "Please answer the question:Do you play video games? " ); return false; }
- if ( ( form.storage[0].checked == false ) && ( form.storage[1].checked == false ) ) { alert ( "Please answer the question:Do you need lot of storage for your files? " ); return false; }
- if ( ( form.type[0].checked == false ) && ( form.type[1].checked == false ) ) { alert ( "Please answer the question:Do you use MSN messenger,Skype or play DVD's? " ); return false; }
- if ( ( form.concern[0].checked == false ) && ( form.concern[1].checked == false )&& ( form.concern[2].checked == false ) ) { alert ( "Please answer the question:What is your main concern? " ); return false; }
- if (ErrorText= "") { form.submit() }
- }
- -->
- </script>
- </head>
- <body bgcolor="Wheat">
- <form name="form" action="handle_form_final.php" method="post">
- <fieldset><legend> Select your Laptop preferences here:</legend>
- <p><b> Where will you be using your laptop?</b> <input type="radio" name="usage" value="home"/>Home
- <input type="radio" name="usage" value="office"/>Office<input type="radio" name="usage" value="both"/>Both</p>
- <p><b> will you be using you laptop on the trains or outside at all?</b> <input type="radio" name="outside" value="yes"/>Yes
- <input type="radio" name="outside" value="no"/>No</p>
- <p><b>Do you play video games?</b> <input type="radio" name="games" value="yes"/>Yes
- <input type="radio" name="games" value="no"/>No</p>
- <p><b> what is your budget range?</b>
- <select name=" Budget_Range" >
- <option value="low">Under £500</option>
- <option value="mid">Under £800</option>
- <option value="high">Over £800</option>
- </select>
- <p><b>Do you need lot of storage for your files?</b> <input type="radio" name="storage" value="yes"/>Yes
- <input type="radio" name="storage" value="no"/>No</p>
- <p><b>Do you use MSN messenger,Skype or play DVD's?</b> <input type="radio" name="type" value="yes"/>Yes
- <input type="radio" name="type" value="no"/>No</p>
- <p><b> What is your main concern?</b> <input type="radio" name="concern" value="price"/>Price
- <input type="radio" name="concern" value="mobility"/>Mobility<input type="radio" name="concern" value="power"/>Power</p>
- </fieldset>
- <div align="center"><input type="button" name="submit" value="Start Search" onClick="ValidateForm(this.form)"></div>
- <input type="reset" value="Reset">
- </form>
- </body>
- </html>
Thanks