Click here to Skip to main content
15,351,641 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
pls help me with the code for this validation process .So that i can do my validate process clearly
Posted

Make use of regular expression[^]
   
Using ASP.NET
ASP.NET
<asp:textbox id="TextBox1" runat="server"></asp:textbox>

<asp:regularexpressionvalidator id="RegularExpressionValidator1" controltovalidate="TextBox1" runat="server" errormessage="Only Numbers allowed" validationexpression="\d+"></asp:regularexpressionvalidator>


Using Javascript
HTML
<input type="text" id="txtID" />

JavaScript
function isNumber(evt) {
    evt = (evt) ? evt : window.event;
    var charCode = (evt.which) ? evt.which : evt.keyCode;
    if (charCode > 31 && (charCode < 48 || charCode > 57)) {
        return false;
    }
    return true;
}
   
v2

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


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