Copy link to clipboard
Copied
Hi there,
A quick question regarding text field validation, please can someone point me in the right direction?
I'm trying to validate a text field, that's a comb of 2 characters, to only allow values from 01 - 11.
Setting the form field format to number means losing the leading zero which I'd like to keep.
So far I've come up with this...
event.rc = true;
if (event.value != "" && event.value != "01" && event.value != "02" && event.value != "03" && event.value != "04" && event.value != "05" && event.value != "06" && event.value != "07" && event.value != "08" && event.value != "09" && event.value != "10" && event.value != "11")
{
app.alert("The entered value needs to be from 01 to 11.");
event.rc = false;
}
This code does what I need however it allows the user to enter anything into the field because there is no format on it.
Is there a nicer way to restrict the user to entering numbers only, check the value is from 01-11 and retain the leading zero?
Thanks in advance 🙂
Whilst looking for something else I found this...
... which answers my question using a custom Keystroke script 🙂
Copy link to clipboard
Copied
Whilst looking for something else I found this...
... which answers my question using a custom Keystroke script 🙂