Click here to Skip to main content
14,694,918 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
validate a text box only enter numeric value in javascript in .NET
Posted

1 solution

try this one....
<asp:RegularExpressionValidator id="RegularExpressionValidator1"  
                       ControlToValidate="TextBox1"  
                       ValidationExpression="\d+"  
                       Display="Static"  
                       EnableClientScript="true"  
                       ErrorMessage="Please enter numbers only"  
                      runat="server"/>

or
function fncInputNumericValuesOnly()
    {
        if(!(event.keyCode==45||event.keyCode==46||event.keyCode==48||event.keyCode==49||event.keyCode==50||event.keyCode==51||event.keyCode==52||event.keyCode==53||event.keyCode==54||event.keyCode==55||event.keyCode==56||event.keyCode==57))
        {
            event.returnValue=false;
        }
    }
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900