Copy link to clipboard
Copied
Hi,
I am creating a form that has an input for phone numbers. I am trying to dynamically limit the field length based on the input from another field (country). If the field is domestic, I want to limit the field to 10 characters, however, if the field is selected as other, then I want to allow up to 20 characters. Is this something that I can do through custom logic?
Copy link to clipboard
Copied
Copy link to clipboard
Copied
You can write this script in onBlur action:
if (this.getField("country").value=="domestic") event.target.charLimit=10;
else event.target.charLimit=20;
Or in custom keystroke script if you know the pattern of both phone numbers, and you place one or two regular expressions.
@+
Copy link to clipboard
Copied
This needs to be done in a different event. Limiting the number of characters after the user exited the field is like closing the gates after the cows have fled... You need to do it before-hand, preferably in an action associated with the other field ("country"), such as the Validation event, or Mouse Up (if it's a check-box).
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Thanks! That's exactly what I was looking to implement. I didn't think that it should have been in the keystroke section to limit while the user is still in the field entry rather than after they've exited
Find more inspiration, events, and resources on the new Adobe Community
Explore Now