Following are some of the useful JavaScript snippets used in ASP.NET WebForms
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Numbers only textbox | |
function IsNumber(evt) { | |
var charCode = (evt.which) ? evt.which : evt.keyCode; | |
if (charCode > 31 && (charCode < 48 || charCode > 57)) | |
return false; | |
return true; | |
} | |
<asp:TextBox ID="txtNumbersOnly" runat="server" onkeypress="return IsNumber(event)"></asp:TextBox> | |
//Select all text when focus | |
<asp:TextBox ID="txtSelectAll" runat="server" onfocus="this.select();"></asp:TextBox> |
Comments
Post a Comment