Text box can only select data to text box to prohibit manual input

  • 2020-03-29 23:58:31
  • OfStack

There is a problem in striking today. Text box can only go on the home select data. Cannot be entered manually. I looked it up. The final solution is as follows.

Page code:
<asp:TextBox ID="txtcategory" readonly="true" Width="300" CssClass="txt" runat="server"></asp:TextBox> 

Script (used when assigning values to text boxes) :
$("#id").removeAttr("readonly"); //Remove the readonly attribute
$("#id").val( "Your value" ); 
$("#id").attr("readonly","readonly"); //Add the readonly attribute

So you have this little feature
[/ code]

Related articles: