Skip to main content
August 7, 2019
Answered

how can I restrict a field to only choosing one of two letters, for example the letter "I" or "X"

  • August 7, 2019
  • 1 reply
  • 686 views

This topic has been closed for replies.
Correct answer try67

it worked but not exactly the way i wanted it to,with your suggested custom validation script if you enter any letter other than X and I it will automatically replace that letter with X or I, and what i want it to be doing instead is not be able to enter that letter from the first place and maybe give and alert that you can only enter the letters X or I


No, it doesn't replace what you enter, but it does reject it and revert to the previous value.

To do what you described you would need a Keystroke script, like this:

if (event.value) event.rc = (AFMergeChange(event)=="I" || AFMergeChange(event)=="X");

if (!event.rc) app.alert("You must only enter \"X\" or \"I\".");

It's possible the code will "disappear" once you enter it, but it should still work.

1 reply

try67
Community Expert
Community Expert
August 7, 2019

A custom validation or keystroke script can be used, but wouldn't it be easier to simply using a drop-down with just those options, instead?

August 8, 2019

what custom validation or keystroke script would i use in this case ?

try67
Community Expert
Community Expert
August 8, 2019

A custom validation script could be something like this:

if (event.value) event.rc = (event.value=="I" || event.value=="X");