Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Entering specific numbers in form fields

Status
Not open for further replies.

jpgoossen

IS-IT--Management
Apr 26, 2007
25
NL
Hi all,

After having a lot of help on some other issues yet, I have some "filling in forms" questions.
I have some time fields that are entered. The data is saved as numeric, not as a date field. The data entry person may vary and thus, people will try to enter stuff like 0.1 (for six minutes) and the like. I would prefer to only allow times to be either whole hours, or end in .25, .50 and .75 (for increments of 15 minutes. How do I prevent users from entering other values?

I also find that, when I set a default value (0, in this case, to prevent errors when making calculations based on these fields) that users may enter a single digit number and end up with a double digit number. They type in 3, and end up with 30 in the field, because they do not check to see if they are overwriting the default value already in the field. How do I make sure that any 0 or other value already in the field, automagically gets overwritten.
The same happens with my week numbers. When users enter a 2, for week 2, it automagically goes to 20, in a combo box, instead of defaulting to 02.
Data entry issues galore, I would think.

Any tips or tricks?

Thanks in advance,

Patrick
 
I can think of a couple of ways to validate the even quarter-hours rule. The easiest is probably to multiply the number by 4 and see if you have an integer. If not, flag the field and instruct the user to enter appropriate data.

For the exploding zeros, I'd suggest setting up code for OnEnter and OnExit. OnEnter, if the value in the box is "0", change it to "". OnExit, if the value is "", change it to "0".

TMTOWDI - it's not just for Perl any more
 
Adalger,

Thanks for your reply. The OnEnter and OnExit works, but it does require me to switch off "Field is required", since the value "" is not valid for a required field. But that is fine, since it does fill in at least a numeric value (0) OnExit, so no problem with invalid numeric fields in calculations.

The multiplying by 4 sounds good, but cannot seem to figure out how to test for an integer. Rounding or converting to an Integer works fine, but I do need and want to keep the decimal value in the field. Would converting the decimal value to a string and then testing on either "", "00", "25", "50" or "75" be an option? The value is not SAVED as a string, it is just for the validation. It sounds like a rather roundabout way though, so any suggestions how to do this easier is welcome.

Thanks so far,

Patrick
 
This:

[tt][DecFieldName]-Int([DecFieldName]) In (0,0.25,0.5,0.75)[/tt]

Will work as a validation rule. You may need to add a test for Nulls.

Null is permitted for required fields, so you can test for Null on enter and on exit. This works well with numeric fields.

 
Remou,

The check on quarts does not seem to work. At first I had some problem with the stupid different settings over here (our decimal point is a comma, so had to adjust). After that it seems to check for valid entries, but never disallows any entries, even if I specifically try to enter illegal values. I had to use semi colon (;) as list separator in the In clause. Not sure if that is correct here?

TIA,

Patrick
 
Adalger,

The OnExit and OnEnter proved to be a bit cumbersome. It now emptied fields. I found however, that adapting the input mask enabling the first position to be a space, would simply do the trick. See how we can sometimes think way too complicated for simple things.

Thanks for helping out.

Cheers,

Patrick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top