<html>
<head>
<script language="javascript">
function funSummery()
{
var msg="Name - " + form1.txtName.value + "\n\n"
msg += "Gender - "
if(form1.gender[0].checked)
msg += form1.gender[0].value
else if(form1.gender[1].checked)
msg += form1.gender[1].value
msg += "\n\n"
msg += "Favorit sports - \n"
if(form1.chkCricket.checked)
msg += "Cricket \n"
if(form1.chkHockey.checked)
msg += "Hockey \n"
if(form1.chkBasketball.checked)
msg += "Basketball \n"
if(form1.chkFootBall.checked)
msg += "FootBall \n"
msg+="\n"
msg += "Current Year Of Study: " + form1.cmbYear.options[form1.cmbYear.selectedIndex].text
alert (msg);
}
function formValidation()
{
if(form1.txtName.value == "")
{
alert("Please Enter Name");
form1.txtName.focus();
}
else if(!form1.gender[0].checked && !form1.gender[1].checked)
{
alert("Please select gender");
form1.gender[0].focus()
}
else if(form1.cmbYear.selectedIndex==0)
{
alert("Please select Year");
form1.cmbYear.focus()
}
}
</script>
</head>
<body>
<form name ="form1">
<p>
Enter Name : <input type="textbox" name="txtName"> </p>
<p>
Gender: <br>
<input type="radio" name="gender" value="Male">Male
<input type="radio" name="gender" value="Female">Female
</p>
<p>
Favorit sports: <br>
<input type="Checkbox" name="chkCricket">Cricket <br>
<input type="Checkbox" name="chkHockey">Hockey <br>
<input type="Checkbox" name="chkBasketball">Basketball <br>
<input type="Checkbox" name="chkFootBall">FootBall <br>
</p>
<p>
Current Year Of Study: <br>
<select name="cmbYear">
<option value="first"> --Select One--</option>
<option value="1">First Year</option>
<option value="2">Second Year</option>
<option value="3">Third Year</option>
</select>
</p>
<input type="button" name="Summery" value = "Summery" onclick="funSummery()">
<input type="button" name="Validation" value="Validation" onClick="formValidation()">
<form>
</body>
</html>