There are two basic things i need to get help with:
1. A selection from the list in question 3 can only be made if the user selected at least 1 check box in question
2. If the user enters a valid value in the question 5 text box then the script should automatically select the Yes
radio button in question 4. The amount entered in the text box must be numeric, not negative and not
greater than 1000.
<?xml version="1.0" encoding="UTF-8"?>
<!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" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Script-Type" content="text/javascript"/>
<!--Styles-->
<style type="text/css">
body
{
font-family:verdana,Arial, Helvetica, sans-serif;
color:#00CCFF;
font-family:"Verdana";
font-size:13px;
line-height:150%;
margin-left:3em;
}
h1
{
color:#00CCFF;
font-family:"Verdana";
font-size:1cm;
line-height:150%;
margin-left:3cm;
}
h2
{
color:#00CCFF;
font-family:"Verdana";
font-size:16px;
line-height:150%;
margin-left:4cm;
}
select
{
color:#6699FF;
margin-left:20px;
background:#E0E0E0;
}
input
{
color:#6699FF;
margin-left:20px;
background:#E0E0E0;
}
input[type="text"]
{
width:150px;
margin-bottom:10px;
border: 0px;
}
input[type="submit"]
{
width:120px;
margin-left:20px;
border: 1px solid #808080;
}
input[type="reset"]
{
width:120px;
margin-left:5px;
border: 1px solid #808080;
}
table
{
color:#00CCFF;
font-family:"Verdana";
font-size:13px;
line-height:150%;
}
</style>
<title>TWA Prac Set 2 - Task 2</title>
</head>
<body>
<h1>Get Me Fit Quick - Quick Member Survey</h1>
<p>Please take a minute to fill in the form below. We value your feedback - thanks</p>
<form method="post" id="f1" action="http://tl28serv.uws.edu.au/twainfo/form.asp" onsubmit="return validate(this);" >
<!--Tick Boxes-->
<p>Q2. Which of our classes have you attended?</p>
<table>
<tr>
<td><input type="checkbox" name="classes" id="aerobics" value="aerobics" /><label for="aerobics"> Aerobics</label></td>
</tr>
<tr>
<td><input type="checkbox" name="classes" id="boxing" value="boxing" /><label for="boxing"> Boxing</label></td>
</tr>
<tr>
<td><input type="checkbox" name="classes" id="circuitclass" value="circuitclass"/><label for="circuitclass">Circuit Class</label></td>
</tr>
<tr>
<td><input type="checkbox" name="classes" id="weighttraining" value="weighttraining" /><label for="weighttraining">Weight Training</label></td>
</tr>
</table>
<!--Drop Down Menu-->
<p>Q3.Which of the above classes has been most beneficial for you?
You can only choose one from the list:
<select name="class1" size="1">
<option value="PC" >--Please Choose--</option>
<option value="Aero" > Aerobics </option>
<option value="Box">Boxing</option>
<option value="CC">Circuit Class</option>
<option value="WT">Weight Training</option>
</select>
</p>
<!--Radio Buttons-->
<p>Q4.Do you think that you are recieving good value for money from your membership?</p>
<table>
<tr>
<td><input type="radio" name="Mem" id="Y" value="Y"/><label for="Y">Yes</label></td>
</tr>
<tr>
<td><input type="radio" name="Mem" id="N" value="N" /><label for="N">No</label></td>
</tr>
</table>
<!--Text Box-->
<p>Q5.If you answered <b>YES</b> to the question above,how much more would you be willing to pay for your membership?
$ <input type="text" name="dollar" size="10" maxlength="7"/>
</p>
<p>
<input type="submit" value="Finished Survey"/>
<input type="reset" value="Reset"/>
</p>
</form>
</body>
</html>
Thats my html and java code is:
function validate(form)
{
var booValid = true;
var strErrorMessage = "";
if( (! form.visits[0].checked) && (! form.visits[1].checked) && (! form.visits[2].checked) && (! form.visits[3].checked) && (! form.visits[4].checked) )
{
strErrorMessage += "You must answer Question 1 before submitting the form!\n";
booValid=false;
}
if( ( form.visits[4].checked) && ( form.classes[0].checked) || ( form.classes[1].checked) || ( form.classes[2].checked) || ( form.classes[3].checked) )
{
strErrorMessage += "You cannot select any options in Question 2 if you have not visited since joining!\n";
booValid=false;
}
if(!booValid)
{
alert(strErrorMessage);
}
return booValid;
}
I need urgent help!!:S