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

Question

Question

Restrict special characters in Forms

asked on February 11

Hi There, I am having trouble with validation on a text field on a form.  I want to prevent the entry of special characters, particularly &, %, $, #.  These characters ruin a URL construction that gets sent out.  When those characters are included, the url won't work.  I tried \w* and it works to an extent.  It certainly prevents the characters, but unfortunately, I need people to be able to enter multiple words.  It is a single line field where they enter their company name.  I know i am jsut missing something in the expression validation, but i am unable to build a solution.  Thanks!

0 0

Answer

SELECTED ANSWER
replied on February 12

Hi John-Paul

Rather the excluding characters, you may find it easier to state what characters are valid.

Something like this may work better. This will allow any number or letters, numbers or spaces in the field. And other character outside of this constraint will show invalid input

[a-zA-Z0-9\s]+

0 0
replied on February 12

Hi Steve, that is a great idea!  It certainly works.  I added [a-zA-Z0-9,\s]+ to allow for our folks that are ", LLC" or some other thing.  I really appreciate the insight!

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.