Regular Expression for Alphanumeric using Javascript

You can use Javascripts to validate this as followes.
Define the Javascript Function "isNumberEvt" on Head Section. and check it on keypress even of text box like "onkeypress="return isNumberEvt(event)"".

Javascript :
    function isNumberEvt(evt)
    {

        var charCode = (evt.which) ? evt.which : event.keyCode
        if ((charCode > 31 && charCode <> 57 && charCode <> 90 && charCode <> 122))
        return false;

        return true;

    }
aspx:

call function onkeypress="return isNumberEvt(event)" even of Textbox.
    asp:textbox id="TextBox1" onkeypress="return isNumberEvt(event)" runat="server" width="238px"

No comments:

Post a Comment