Hi Genit,
Sigrid is absolutely right if your goal is to remove all special characters. If you'd like to allow certain characters, you can simply include them inside the brackets of the replace expression.
For example, if you want to remove most special characters but keep underscores and dashes, you can use:
str = str.replace(/[^a-zA-Z0-9_-]/g, '');
This way, you can easily customize the rule to fit your needs.
Thanks,
Divya
------------------------------
Divya Verma
*Precisely Software Inc.
------------------------------
Original Message:
Sent: 11-14-2025 17:16
From: Sigrid Kok
Subject: Custom Rule to remove special characters
Hi Genit
There is a way without JS using the Translate function, but it does one character or string at a time

Not an expert in JS, but after a bit of searching and trial and error, this seems to work - only allowing alphabetic and numeric entries. There may be a more elegant way, but this works. Please adjust the regex as needed.

JS code:
let str = $form.getValue('/my:myFields/my:Inputfield');
str = str.replace(/[^a-zA-Z0-9]/g, '');
$form.setValue('/my:myFields/my:Inputfield',str);
Before right as I'm entering

After I tab away

HTH,
Sigrid
------------------------------
Sigrid Kok
*Precisely Software Inc.
Original Message:
Sent: 11-14-2025 13:49
From: Genit Parrell
Subject: Custom Rule to remove special characters
Hello,
I need help with formulating a custom rule to remove special charaters.
$form.setValue('/my:myFields/my:ISS/my:HelperPRT',let clean = yourString.replace(/[-.]/g, ''));
Any input is appreciated.
Thank you
------------------------------
Genit Parrell
Pactiv Evergreen
------------------------------