Is it possible to
force a numeric pattern to display a pattern like XXXXX-XXX no matter how many numbers are entered? I want to lock the field to 8 numeric characters (without using a comb), and a hyphen between the 5th & the sixth. Currently, my field forces the pattern, but if I put in more than 8 characters, the pattern goes away, and allows a new pattern like this: XXX,XXX,XXX
Is this possible? If so, please walk me through the process.
Thank you!
Views
Replies
Total Likes
You need to limit the number of characters allowed in the field to 8. You can do this with a script on the change event using javascript.
if(xfa.event.newText > 99999999 || xfa.event.newText < -99999999) { xfa.event.change = "";}
Views
Replies
Total Likes
if (xfa.event.newText.length > 8)
xfa.event.change="";
That will work with both text and numeric input. It's also a bit shorter and easy to manipulate.
Kyle
Views
Replies
Total Likes
I tried both of your suggestions, and it didn't quite work the way I need the field to work. I want to limit the field to 5 characters, hyphen, three characters (zzzzz-zzz), and no more. Currently, even with your suggested javascript codes, if the user enters more than eight characters, the input mask changes to zzz,zzz,zzz. I would like to lock the value so no one can enter more than 8 characters, with the mask defined in my second sentence.
Views
Replies
Total Likes
You just need to set an input pattern, like:
num{99999-999}
Views
Replies
Total Likes
When I set the input pattern you suggest,
and enter more than 8 characters (i.e. 111111111), an error pop-up states "NumericField2 Validate failed". When I click the "OK" button on the error pop-up, the field fills with 111,111,111, allowing the entry. Can the field not lock the entry to my input mask pattern?
Views
Replies
Total Likes
You do not need a validation pattern here because you are checking the input with the script.
Try like this..
Display Pattern: num{99999-999}
Edit Pattern: num{99999999}
No Validation Pattern.
In the Change event of the NumericField put the following code..
if (xfa.event.newText.length > 8)
xfa.event.change="";
Thanks
Srini
Views
Replies
Total Likes
That did it!
I guess I do not understand the difference of the "Display" and Edit" pattern. I thought you would have the same patten in each. Also, FormCalc & Javascript are still a bit foreign to me. Thank you for providing the script.
Views
Replies
Total Likes
Display is what the user sees when they exit the field, Edit is what the user types in.
Views
Replies
Total Likes
Views
Likes
Replies