Skip to main content
ronaldr75691821
Participant
January 30, 2019
Answered

Script that replaces all separators (spaces, commas, etc) with underscores in form field. Thanks.

  • January 30, 2019
  • 1 reply
  • 552 views

Hi,

I am looking for help creating a script which will replace all separators (spaces, commas, dashes, etc) with underscores in a form I have created.

Ex. "2019-RM-15" or "2019 RM 15" becomes "2019_RM_15"

I there a way to do this?  Thanks!

This topic has been closed for replies.
Correct answer try67

You can use this code as the field's custom validation script:

event.value = event.value.replace(/[\s-,]/g, "_");

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
January 30, 2019

You can use this code as the field's custom validation script:

event.value = event.value.replace(/[\s-,]/g, "_");

ronaldr75691821
Participant
January 30, 2019

It worked perfectly.  Thank you very much for your speedy assistance!!