In this article I will explain how to enable or disable TextBox controls in web applications using jQuery.
First we download the file:
These files are added to the project, then use the following procedure.
Program
Enable_Disable_Control.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Enable & Disable textbox Controls</title>
<script src="jquery.min.js" type="text/javascript">
</script>
<script type="text/javascript">
$(document).ready(function () {
$("#btnEnable").toggle(function () {
$('input[type="text"]').removeAttr('disabled');
}, function () {
$('input[type="text"]').removeAttr('disabled');
});
});
$(document).ready(function () {
$("#btnDisable").toggle(function () {
$('input[type="text"]').attr("disabled", "disabled");
}, function () {
$('input[type="text"]').attr("disabled", "");
});
});
</script>
</head>
<body>
<h3 style="color: #0033CC"> Enable And Disable Textbox Control in Jquery</h3>
<form id="form1" runat="server">
<table>
<tr>
<td><b>First name:</b></td>
<td><input id="Fname" type="text" /></td>




Comments
Join the conversation! Your thoughts help the community grow.