997
Views
2
Comments
How way to use regex_search for validate only alpha numeric
Discussion

i want use regex_search to validate form input in login view, but i don't know way to use it any example to use this regex for validate that user only can input alpha numeric?

2016-04-22 00-29-45
Nuno Reis
 
MVP

I'm guessing you are looking for a valid username.

There are two options:

1) get all alphanumeric characters in username and see if it matches the username exactly.

2) get all non-alphanumeric characters in username and see if it has size>0.

I'd rather do number 2) and used the invalid characters in the feedback, as in "you can't use * in the username".


The alphanumeric characters are represented by \w. The non-alphanumeric by \W.


2018-07-03 08-33-54
Tiago Gafeira
Champion

Hi Erron,

Is it something like this that you're looking for?





Cheers,

Tiago.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.