jQuery Enable Disable Textbox on Checkbox Selection

jQuery Enable Disable Textbox on Checkbox Selection:



Today we are going to make a example of make enable and disable a particular asp.net textbox by Jquery. we see this is Jquery.


<script type="text/javascript">
$(function () {
$('#chk1').change(function () {
var status = this.checked;
if (status)
$('#txt_name').prop("disabled"false);
else
$('#txt_name').prop("disabled"true);
})
})
</script>

Now for using this Jquery we create a asp.net page.

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>On Checkbox Selection Enable or disable Jquery</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script type="text/javascript">
$(function () {
$('#chkSelect').change(function () {
var status = this.checked;
if (status)
$('#txt_name').prop("disabled"false);
else
$('#txt_name').prop("disabled"true);
})
})
</script>
</head>
<body>
<form id="form1">
<div>
Select Checkbox: <input type="checkbox" id="chk1" checked="checked" /><br />
Enter UserName:<input type="text" id="txt_name" />
</div>
</form>
</body>
</html>

for this example we are easily create a page and use Jquery in asp.net.

Comments

Popular posts from this blog