Find and Replace using Regex To Modify Input Value

Two Questions:

  1. Goal is to get rid of all alpha and numeric characters from an entered string in one input element and set a second input element equal to the modified string. The modified string should only have special characters or be blank when done. I’m creating a custom state in a workflow action using a find and replace, and setting the second input element equal to the custom state value.

When i run it, I get the same value in the second input element that was entered in the first input element. Not sure why. I’m using the same regex in a Run Javascript and I get the correct modified string when I display it in console.

  1. Once I get this working, I would to only use one input element for both the entry of the original value and the display of the modified value. I tried grouping the first input element and setting the group element to the value of the custom state. And then the initial content of the input element to the parent group thing. But that doesn’t work.

Any assistance how I can accomplish this is appreciated.

Remove the first /and the /g

Well that was too easy… :slightly_smiling_face:

Any ideas on the second question?

Just to clarify you want to display both original and modified values as one string in an input yes?

If yes then you’re going to need a workflow to merge both values into your custom state then run a reset input action so the input retrieves the merged value from the state. Your input’s initial content should be pointed to the state.

I want to replace the original value with the modified value. So if they entered,

FE53#$

I would end up displaying

#$

I hope to display an alert as an error message in between that says something like “Special Characters only” and when they exit out of the alert, then the displayed value is changed.

I have an alert that displays a message. Next issue would be to handle the queuing of the message first and then the display of the modified value so that one doesn’t happen until after the first (alert) is handled.

Ah I see, then it’s the idea. Store the final value into the state and run a refresh input action so the input will retrieve the new value. If the refresh input action doesn’t work then use the refresh data action and apply it to the input’s parent group.

when you say refresh data are you suggesting reset data action?

Ah yes my bad i meant reset data.

So what I did was put the input element into a Row Group. Set the Row Group to the custom state value. And the Input element to the Row Group thing. And added a Reset Data action as the last action in the workflow (the other action is setting the custom state value to the modified string value based on the Regex). Doesn’t work. All I get is a blank value in the input element. I also try Reset Input action, but same result.

1 Like

Got it to work. Didn’t have a type set to text. Thanks for your help.

This topic was automatically closed after 70 days. New replies are no longer allowed.