Click here to Skip to main content
15,884,986 members
Please Sign up or sign in to vote.
2.33/5 (3 votes)
See more:
dear Sir

I have two textbox and i want user to input only Numeric figure and dot(.)in textboxt.
How can i do this?

thaks in advance
ajit vyas
Posted
Comments
Pheonyx 14-Apr-14 9:39am    
What type of application are you writing?
There are different approaches to input validation depending on the type of application you are trying to write.

Also, Have you even tried to google this, I know there are hundreds if not thousands of results showing how to do this for each type of application, some use masking, some use Regular Expressions, some uses javascript, some uses custom controls.
Ajit vyas 17-Apr-14 8:38am    
very thannks
I am writing bodymax index for showing people their fitness accorging to his weight.
I want user use only numeric figure not any string or figure in word.at time of entering input i would like to prevent him to capture what he enters.
I think you got the point.
thanks
Ajit vyas
Sergey Alexandrovich Kryukov 14-Apr-14 12:29pm    
Not a question. Your user does it, not you. What's the problem?
—SA

1 solution

There are two basic approaches: for WinForms, I would strongly recommend using a NumericUpDown class[^] instead of a textbox - not only does it allow you to set a max and min value that is allowed, but it also converts to a number for you automatically.

For a web based solution, you are best with a Javascript solution of some kind. There is a good one here: http://www.javascript-coder.com/html-form/javascript-form-validation.phtml[^] but you must remember to still do validation on the server as well!
 
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