Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validation by alpha fails if the field contains spaces #56

Closed
akobrina opened this issue Oct 24, 2014 · 1 comment
Closed

Validation by alpha fails if the field contains spaces #56

akobrina opened this issue Oct 24, 2014 · 1 comment

Comments

@akobrina
Copy link

The regular expression for the alpha rule looks as follows:
!preg_match("/^([a-zÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ])+$/i", $input[$field]

However, this creates a problem if the field contains spaces, e.g. two words. I had to update the code to include the spaces as valid characters to avoid being given an error. Here is my updated reg ex:
!preg_match("/^([a-zÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ\s])+$/i", $input[$field]

@sn
Copy link
Member

sn commented Aug 6, 2015

There's a validator called alpha_space that will do this exact thing. Have you tried it?

@sn sn closed this as completed Aug 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants