I just realized we can use the attributes in the input widget to set the regex pattern for the input. However, how do I set the error message that was being occurred?
In this request name I set regex such that it can only accept alphabets ("^[A-Za-z]+$")
For instance, without input, the error message will display "This field is required".
If there is an invalid input such as special characters or numbers the error message will display, "Enter a valid text."
This is the configuration for the input widget.
Is there a way to override the "Enter a valid text." to, " Can only be in alphabets"?
I have tried using the set ValidMessage on client action, however, it will render both (Empty input & Wrong input) with the same error message that is set.
Hi Chin Kai,
If you want to override that message you can simply change it here, but its not the best solution because if you have multiple input that have different regex pattern, so every field will have different message.
The best way is to make it custom validation , when you save that form..you need to validate the input using Regex_Search with your regex pattern.
Please find attached oml file for your reference.
Thanks,
Regards,
Aqil
Hi Aqil, Thank you so much!
{but its not the best solution because if you have multiple input that have different regex pattern}
okay I understand what you mean because this set up is for the entire project, so whichever screen that has this input will be affected or receive the same "Error Message" I saw the regex, Great Work! Thanks!
Yes exacty! no problem..happy coding!
As an additional suggestion, I would recommend using an input mask to prevent the user from keying in anything other than alphabets. This way, there's no need to click the save button and validate... but it all depends on your requirements.
There are some input mask component in the Forge, this is one of it, so you can explore this:
Input Mask Reactive
Thanks for suggesting another alternative solution, will look into that as well. Cheers!