Link to home
Create AccountLog in
Avatar of banana_split
banana_split

asked on

asp.net required field validator - accept only numbers.

Hi,

I have a textbox controll and a required field validator field. How can i ensure that my textbox only allows the entry of numbers and not text?

Thanks
Avatar of Pratima
Pratima
Flag of India image

try this on textbox control

onKeypress="if (event.keyCode < 46 || event.keyCode > 57) event.returnValue = false;"
Avatar of banana_split
banana_split

ASKER

is there a way to control this using an expression on the validation controls instead?
you can use  required field validator and the above code .
the above acode dose not allow to enter only digits
sorry
the above acode allow to enter only digits
Okay but where should i put the code at on the textbox control or on the required field validator? can you show me an example? thanks
ASKER CERTIFIED SOLUTION
Avatar of Pratima
Pratima
Flag of India image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
THANKS GOT IT!
HI but there is a problem. it only works for Internet Explore, it does not work with firefox