Copy link to clipboard
Copied
Hello,
I have a text field in my form that I'm trying to see if there is a way to « force » a certain format. So basically, I want them to put their postal code in that format : H1H 1H1 (letter - number - letter - space - number - letter - number). I also want the letters to be in capital letter. Is that possible and if so , how ?
Thank you !
Copy link to clipboard
Copied
Go to field properties -> Format tab, select 'Special' then 'Arbitrary Mask' and input this:
A9A 9A9
To make it all capital letters as 'Validation' script use this:
event.value = event.value.toUpperCase();
Copy link to clipboard
Copied
Go to field properties -> Format tab, select 'Special' then 'Arbitrary Mask' and input this:
A9A 9A9
To make it all capital letters as 'Validation' script use this:
event.value = event.value.toUpperCase();
Copy link to clipboard
Copied
Thank you so much !
Copy link to clipboard
Copied
I am already using Custom Format Script to define placeholder/instructional text, and therefore Arbitrary Mask solution above is unavailable to me.
Is there another solution to achieve this result, perhaps a custom validation script?
Copy link to clipboard
Copied
You can try something like this as custom format script:
if(event.value)
event.value = util.printx("A9A 9A9", event.value);
else
event.value = "Instructional text";
Copy link to clipboard
Copied
Thanks, i wasnt able to get that to work as i intended.
this is what i am using now:
Custom Format Script
if (!event.value){
event.value = "Click here to enter NAME";
event.target.textColor = color.ltGray;
event.target.display = display.noPrint;
}
else {
event.target.textColor = color.black;
event.target.display = display.visible;
}
when i click the field to enter text, i would like it to format as "AA-AAA-AAAA-999". If i clear the field, i would like it to show the "Click here to..." text in grey again.
Copy link to clipboard
Copied
In the 'else', add 'util.printx' part, with your formatting.
Copy link to clipboard
Copied
I swear I tried that before I responded? But that did the trick. Perfect, Thank you Ms. Nurani for sharing your skill.
Copy link to clipboard
Copied
FYI anyone looking for similar, this was my final solution:
place in Custom Format Script:
if (!event.value){
event.value = "Instructional Text";
event.target.textColor = color.ltGray;
event.target.display = display.noPrint;
}
else {
event.value = util.printx("AA-AAA-AAAA-999", event.value);
event.target.textColor = color.black;
event.target.display = display.visible;
}
Maybe useful to someone else.