Search This Blog

Sunday, May 24, 2015

How to avoid alphabets and special character from text box using javascript

Use the following code OnKeyPress Event in your text box:

<asp:TextBox ID="txtNumber" runat="server" OnKeyPress="return IsNumeric(event);"></asp:TextBox>


function IsNumeric(e) {
    var keyCode = e.which ? e.which : e.keyCode
    var ret = ((keyCode >= 48 && keyCode <= 57) || specialKeys.indexOf(keyCode) != -1);
    document.getElementById("error").style.display = ret ? "none" : "inline";
    //TestOnTextChange();
    return ret;
}

No comments:

Post a Comment

Restricting Custom People Picker to only one Sharepoint group programatically

Refer the following script files in your page,     <!-- For People Picker -->     <script type="text/javascript" src...