Thursday, December 13, 2012

Allow text box only for alphabets using Jquery



$(document).ready(function () {
        $('#<%= txtNoofDays.ClientID  %>').keypress(function (e) {
            if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) {
                //display error message
                $("#errmsg").html("Digits Only").show().fadeOut("slow");
                return false;
            }
        });
       
    });

<asp:TextBox ID="txtNoofDays" runat="server"></asp:TextBox>
                        &nbsp;<span id="errmsg" style="color:Red;"></span>