I want to limit a number field to two digits.
I can do that by sizing the text field and checking "limit length to visible area" in the field properties.
Alternatively, I can set a pattern num{99}. However, if I do this, then if someone enters an alpha character, it converts it into a zero! This is less preferable than the first option, where if someone enters an alpha character it just beeps and won't let them enter it.
Unfortunately, using field size is not always a very convenient way to specify my field format. For one thing, I don't use a fixed-width font, so longer fields with many numbers may not be able to be accurately limited to specific number lengths, since 11111111 takes different space than 888888888. Also, sometimes it is easiest (for cosmetic reasons) to have the field size not determined by my desired number length. Is there a way to both limit field length and to prevent alpha entries from being converted into zeros, without relying on the "limit length to visible area" property?
Thanks
Solved! Go to Solution.
Views
Replies
Total Likes
Sure there is. You can make the field a decimal field by selecting the field and then choosing 'Decimal Field' from the 'Type' dropdown at the top of the 'Field' tab in the 'Object palette. Then just below the 'Patterns' Button in that same menu, you can check the 'Limit Leading Digits' box and insert 2 in the 'Max' box, then de-select the 'Limit Trailing Digits' box.
Views
Replies
Total Likes
Sure there is. You can make the field a decimal field by selecting the field and then choosing 'Decimal Field' from the 'Type' dropdown at the top of the 'Field' tab in the 'Object palette. Then just below the 'Patterns' Button in that same menu, you can check the 'Limit Leading Digits' box and insert 2 in the 'Max' box, then de-select the 'Limit Trailing Digits' box.
Views
Replies
Total Likes
One related question...
One of my fields is a numeric prefix that relates to a fiscal year designation. Some of those are 00, 01, 02, etc., so I need to be able to specify a pattern that will insert the leading zero if someone were to type just one numeric digit. For instance, if they typed just "1" it would enter "01." I don't seem to be able to do this by setting the field type to "decimal" (although that worked like a charm for the rest of my fields).
Any suggestions?
To recap: I need to (1) limit field to two numeric characters, (2) not have the field convert a mistaken alpha entry to a zero, and (3) make sure that the value is padded with leading zeros so as to fill up the entire field.
Views
Replies
Total Likes
One way to do this is to put this JavaScript into the exit event of the field and make sure the language is set to JavaScript :
if(this.rawValue == 1){this.rawValue = '01';}
if(this.rawValue == 2){this.rawValue = '02';}
if(this.rawValue == 3){this.rawValue = '03';}
if(this.rawValue == 4){this.rawValue = '04';}
if(this.rawValue == 5){this.rawValue = '05';}
if(this.rawValue == 6){this.rawValue = '06';}
if(this.rawValue == 7){this.rawValue = '07';}
if(this.rawValue == 8){this.rawValue = '08';}
if(this.rawValue == 9){this.rawValue = '09';}
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies