Step 1:
Code for validation in html
<html>
<body>
<head>
<script type="text/javascript">
function validate()
{
var cmb=document.getElementById("gender");
if(cmb.value=="0")
{
alert("please Select Value");
cmb.style.border = "1px solid #CF3339";
cmb.style.background="#FFFF99";
return false;
}
else
{
cmb.style.border = "";
}
}
</script>
</head>
<body>
<form id="validation" align="center" >
<select name="Gender" id="gender" style="WIDTH: 120px" >
<option value="0">Gender </option>
<option value="1" >Male </option>
<option value="2" >Female </option>
</select><br><br>
<input type="submit" name="submit" value="Submit" onClick="return validate();"/>
</form>
</body>
</html>
Step 2:
Run the Code
Please Enter Submit
Then enter ok
So select Any one of the combobox
Validation Completed
No comments:
Post a Comment
Comment Here..