Copy link to clipboard
Copied
Further, is possible to restrict the text field to letters and hyphens?
Copy link to clipboard
Copied
You can do it using this code as the field's custom Keystroke script:
event.rc = /^[-a-z]*$/i.test(event.change);
event.value = event.value.toUpperCase();
Copy link to clipboard
Copied
You can do it using this code as the field's custom Keystroke script:
event.rc = /^[-a-z]*$/i.test(event.change);
event.value = event.value.toUpperCase();
Copy link to clipboard
Copied
Thank you! I had omitted that the field should be able to accept spaces as well, but then adding a space to the character class, as follows, sorted that out.
event.rc = /^[-a-z ]*$/i.test(event.change);
event.value = event.value.toUpperCase();
Copy link to clipboard
Copied
If you want to show uppercase as soon as you type it, replace:
event.value = event.value.toUpperCase();
with:
event.change = event.change.toUpperCase();
Copy link to clipboard
Copied
"is possible to restrict the text field to letters and hyphens?"
Only letters can be in upper case.
😉