You are viewing limited content. For full access, please sign in.

Question

Question

How can I restrict the use of characters that are not letters or numbers in Forms fields

asked on July 17, 2023

How can I restrict the use of characters that are not letters or numbers in Forms fields. I must then send the data that is captured to SAP using webservices and if the number sign (#) is sent, for example, it cuts the string and the values of the fields that are after that character are not sent.
For this reason I want to control the capture, if it is not possible, I would have to control it in the wf that consumes the webservices and it is also complex to capture the value of the complete field using pattern matching.

0 0

Answer

SELECTED ANSWER
replied on July 17, 2023 Show version history

You can use regular expressions to add constraints. It won't prevent them from inputting the characters outright, but it will fail validation, then you could add a custom error message that tells the user only numbers and letters are allowed.

The following regex requires one or more letters or numbers, but you can look up more about regular expressions if you want to require more than one or anything else.

[a-zA-Z0-9]+

The default validation error will just say "invalid input" so I'd highly recommend adding a custom one for that field that says something more specific like "Letters and Numbers only"

 

Depending on which version of the Form designer you're using, it's possible to further restrict things with JavaScript, but regex is the easiest to implement and maintain.

 

1 0
replied on July 17, 2023

Thanks Jason!

0 0

Replies

You are not allowed to reply in this post.
You are not allowed to follow up in this post.

Sign in to reply to this post.