views:

278

answers:

3

If the user enters non-numeric and numeric values in a textbox, how do I keep only the numeric part?

+3  A: 

Set the property "CausesValidation" to true. Set your validation to accept only an int or whatever sort of number you are looking for.

Perhaps see: http://stackoverflow.com/questions/1394505/number-validation-in-required-field-validator

Degan
+1  A: 

You can use RegularExpressionValidator

Validate it against your control, with the validation Expression of {0:d} to permit only digits or {0:w} for letters and numbers as well.

waqasahmed
+1  A: 

You could bind to the keydown event and if the key is not 0-9 set handled to true.

Petoj