Click here to Skip to main content
16,020,822 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to validate a TEXTBOX entry to be only numeric or in a certain datatype?
Posted

For numeric validation -

VB
Private Sub txt_KeyPress
(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) 
Handles txt.KeyPress

If Char.IsDigit(e.KeyChar) = False And Char.IsControl(e.KeyChar) = False Then
e.Handled = True
End If
End Sub
 
Share this answer
 
v2
add this javascript to you page.

Call this function by sending id you will get numeric text box

function EnterInteger(ID)
{
if(ID.value.length>0)
{
ID.value = ID.value.replace(/[^\d]+/g, '');
}
}

or create regular expression validator with this \d+(\.\d{1,2})?
expression.

You will get numeric text box.
 
Share this answer
 

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