Search the FirstSpirit Knowledge Base
Dear All,
I have to allow any number of white space infront and back of the email address.
Because email address is copied from the webpage and there is a chance of the white space added in leading and trailing of the email address.
To remove leading and trailing whitespace regx:
/^\s+|\s+$/g
How to add the condition in regx?
Thank you.
You could try to create a value service that returns the trimmed address. That value could then be inserted into the form.
But I'm not sure if this is a good solution because an ON_SAVE rule is not only called when you press the save button but many times before while you type. I'm not sure how it will behave if a rule tries to set the value of the form element you're currently editing.
Hello,
this should work:
<MATCHES regex="^\s*.+\@.+\.[a-zA-Z]{2,6}\s*$">
Best regards
Tim
Hello Tim,
The new rule will allow email addresses with leading & trailing whitespaces, whici is ok to remove the error message from the form.
BUT what if still need the value of the email address field to be trimmed? So that further usage of those email addresses (with whitespaces) does not lead to runtime errors.
Is a Trim/modification of the field'S value possible with rules?
You could try to create a value service that returns the trimmed address. That value could then be inserted into the form.
But I'm not sure if this is a good solution because an ON_SAVE rule is not only called when you press the save button but many times before while you type. I'm not sure how it will behave if a rule tries to set the value of the form element you're currently editing.
Hello,
do you need further help or did Tim's answer already help you? If so it would be nice, if you mark his "correct answer".
If you have already found solution by yourself it would be kind if you post it here.
Best regards
Michaela
Hello Michaela Pahl,
Thank you for your reply.Tim answer is hepful.
Thank you.