$(document).ready(function(){
$("#submit").click(function(){
var Sports=$("#Sports").val();
if($('input[id=state]:checked').length<=0){
alert("select atleast one state");
return false;
}else if(Sports==null ||Sports==""){
alert("select atleast one Sports");
return false;
}else if($('input[id=GENDER]:checked').length<=0){
alert("select atleast one GENDER");
return false;
}
else{}
});
});
</script>
</head>
<body>
<center>
<form method="post" action="Jqueryvalidation2.jsp">
<table>
<tr><td>State:</td><td>
<input type="checkbox" id="state" name="State" value="Haryana">Haryana
<input type="checkbox" id="state" name="State" value="New Delhi">New Delhi
<input type="checkbox" id="state" name="State" value="Punjab">Punjab
<input type="checkbox" id="state" name="State" value="Himachal">Himachal
<tr><td>Gender:</td><td>
<input type="radio" id="GENDER" name="Gender" value="Male">Male
<input type="radio" id="GENDER" name="Gender" value="Female">FeMale </td></tr>
<tr><td>Sports:</td><td><select name="sports" id="Sports" style="width:160px">
<option value="">Select</option>
<option value="Hockey">Hockey</option>
<option value="Football">Football</option>
<option value="Baseball">Baseball</option>
<option value="Vollyball">Vollyball</option>
<option value="Tennis">Tennis</option>
<option value="Cricket">Cricket</option>
</select></td></tr>
<tr><td>Submit</td><td>
<input type="reset" name="Reset">
<input type="submit" id="submit" name="submit" value="submit"></td></tr>
</table>
</form>
</center>
</body>
$("#submit").click(function(){
var Sports=$("#Sports").val();
if($('input[id=state]:checked').length<=0){
alert("select atleast one state");
return false;
}else if(Sports==null ||Sports==""){
alert("select atleast one Sports");
return false;
}else if($('input[id=GENDER]:checked').length<=0){
alert("select atleast one GENDER");
return false;
}
else{}
});
});
</script>
</head>
<body>
<center>
<form method="post" action="Jqueryvalidation2.jsp">
<table>
<tr><td>State:</td><td>
<input type="checkbox" id="state" name="State" value="Haryana">Haryana
<input type="checkbox" id="state" name="State" value="New Delhi">New Delhi
<input type="checkbox" id="state" name="State" value="Punjab">Punjab
<input type="checkbox" id="state" name="State" value="Himachal">Himachal
<tr><td>Gender:</td><td>
<input type="radio" id="GENDER" name="Gender" value="Male">Male
<input type="radio" id="GENDER" name="Gender" value="Female">FeMale </td></tr>
<tr><td>Sports:</td><td><select name="sports" id="Sports" style="width:160px">
<option value="">Select</option>
<option value="Hockey">Hockey</option>
<option value="Football">Football</option>
<option value="Baseball">Baseball</option>
<option value="Vollyball">Vollyball</option>
<option value="Tennis">Tennis</option>
<option value="Cricket">Cricket</option>
</select></td></tr>
<tr><td>Submit</td><td>
<input type="reset" name="Reset">
<input type="submit" id="submit" name="submit" value="submit"></td></tr>
</table>
</form>
</center>
</body>
No comments:
Post a Comment