Click here to Skip to main content
14,732,921 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
can someone tell me how to check the data type of a text field while the user is entring information. for example, if I am expecting an int in a text field and the user enters "fgze", I want to display a lable that tell him an integer is expected.

Control the keydown event and show the label if the char introduced is not something allowed.

Note: You can add the event for the editbox in the dialog editor right clicking the element and setting the right properties.

You should discard the event depending on the key that has been pressed...

i.e. if a number is pressed you should process it normally, but if it is a letter or any other thing, then you should break the message execution.

[Adding to Joan's answer]

You can also use controls specific to the data type. Example a date-time control for time, a numeric textbox for integers, a masked text box for currency, an IP address control for IP addresses etc.
Niklas L 29-Apr-11 3:49am
This is the best solution. Don't give the user a chance to make a mistake. High 5.
Nish Nishant 29-Apr-11 9:12am
Use the style ES_NUMBER.

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