Loading ...

Enable/Disable input field using Jquery | CodeAsp.Net

Enable/Disable input field using Jquery

 /5
0 (0votes)

In this blog i will explain you how to enable/disable textbox using jquery.

<html xmlns="http://www.w3.org/1999/xhtml">

<head >

<title></title>

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>

</head>

<body>
<form id="form1" runat="server">
<div>
<input id="txtName" type="text"  value="disabled" />
<asp:Button ID="btnCancel" runat="server" Text="Cancel" />
</div>
</form>
</body>

<script type="text/javascript">

$(function()
{
$('#txtName').attr('disabled', true);

});

$('#<%=btnCancel.ClientID %>').click(function(e)
{
e.preventDefault();
$('#txtName').val('enabled');
$('#txtName').removeAttr('disabled');
});

</script>

</html>


That's all!

Comments (no comments yet)

Top Posts