Validations using JQuery
<html>
<head>
<title>Validations using JQuery</title>
<script type="text/javascript" src="jquery-1.4.2.min.js"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function()
{
$("#btnValidate").click(function()
{
if($("#txtValidate").val()=="")
{
alert('Please enter some thing in TextBox');
return false;
}
if($("#ddlValidate").get(0).selectedIndex==0)
{
alert('Please select a valid Option');
return false;
}
if(!$("#chkValidate").get(0).checked)
{
alert('Please select CheckBox');
return false;
}
});
});
</script>
</head>
<body>
<table cellpadding="0" cellspacing="0">
<tr><td colspan="2" align="center" style="font-weight:bold;">Validations using JQuery</td></tr>
<tr><td>Validate TextBox</td><td><input type="text" id="txtValidate" /></td></tr>
<tr><td>Validate DropDown</td><td><select id="ddlValidate"><option value="Select">Select</option><option value="A">A</option></select></td></tr>
<tr><td>Validate CheckBox</td><td><input type="checkbox" id="chkValidate" value="Validate CheckBox" /></td></tr>
<tr><td colspan="2" align="center"><input type="button" value="Validate Controls" id="btnValidate" /></td></tr>
</table>
</body>
</html>
<head>
<title>Validations using JQuery</title>
<script type="text/javascript" src="jquery-1.4.2.min.js"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function()
{
$("#btnValidate").click(function()
{
if($("#txtValidate").val()=="")
{
alert('Please enter some thing in TextBox');
return false;
}
if($("#ddlValidate").get(0).selectedIndex==0)
{
alert('Please select a valid Option');
return false;
}
if(!$("#chkValidate").get(0).checked)
{
alert('Please select CheckBox');
return false;
}
});
});
</script>
</head>
<body>
<table cellpadding="0" cellspacing="0">
<tr><td colspan="2" align="center" style="font-weight:bold;">Validations using JQuery</td></tr>
<tr><td>Validate TextBox</td><td><input type="text" id="txtValidate" /></td></tr>
<tr><td>Validate DropDown</td><td><select id="ddlValidate"><option value="Select">Select</option><option value="A">A</option></select></td></tr>
<tr><td>Validate CheckBox</td><td><input type="checkbox" id="chkValidate" value="Validate CheckBox" /></td></tr>
<tr><td colspan="2" align="center"><input type="button" value="Validate Controls" id="btnValidate" /></td></tr>
</table>
</body>
</html>
No comments:
Post a Comment