Change Default Regex Message

Hello again!

Is it possible to alter the error message of a failed regex tied to a text input from the system default "Please match the requested format" to something custom such as "please enter valid number"?


You can create a custom rule for your input. Something like:

{{ textInput2.value.match(/^[0-9]+$/) == null ? "Only numbers pls" : ""}}

Would that work for you?

1 Like

Hi @minijohn

I got some errors when trying to use that. Here is my current regex: "\b{{['Last 4 SS']}}\b"

That regex queries the DB and if the number does not match it shows that validation error of "Please match the requested format". How would you use the custom rule for that regex and have error message as "please enter valid SSN"?

Thanks again!

So the regex in itself can't query the DB, it will execute on a string (that can come from the DB).

If you want to show query6's results in the textInput1 and have custom validation logic on the input you can:

  • Set the value of the input to {{['Last 4 SS'] }}
  • Set the custom rule to {{ textInput1.value.match(/([0-9])\w+/) == null ? "Please enter a valid SSN" : "" }}
  • Set the max length of the input to 4

The match function may not return null, you'll need to have a look there :sweat_smile:

1 Like