regex code for text entry | XM Community
Solved

regex code for text entry

  • 11 April 2024
  • 2 replies
  • 23 views

Badge +1

i have text entry field for user to input medical diagnosis. how can i restrict user to enter only alphabets, numbers, and a few other punctuation marks eg comma, fullstop, dash, apostrophe?

ultimate plan is to prevent users from entering something like a smiley etc.

thanks!

icon

Best answer by omkarkewat 11 April 2024, 11:11

View original

2 replies

Userlevel 5
Badge +12

 hi @sics_sue_choo The below regex will allow strings that contain only alphabets, numbers, commas, full stops, apostrophes, spaces, and dashes. It will reject strings that contain any other characters, such as smileys or special symbols. You will need to add the characters, symbols in the below regex code that can be allowed in the open text box.

^[a-zA-Z0-9,.'\s-]+$

Badge +1

thanks!!

Leave a Reply