Problems, need help? Have a tip or advice? Post it here.
6 posts Page 1 of 1
Hi,
I chanced upon this problem today when I tried using the validator=alpha validation in a text form input field which is meant to capture names . The validation see spaces between the first name and last name as a number and so returns an error.

Is that supposed to be a default behaviour?
Hi,

The 'alpha' validator only allows 'a-z' and 'A-Z' characters, so the space character wouldn't pass it.
That said, the first and second names, IMHO, should be two separate inputs.
Ok KK, thank you very much. Will separate them then. Wanted a single input field for both
adimpressions wrote: Wanted a single input field for both

A custom validator would help here. Use this Regex for validation [a-zA-Z][a-zA-Z ]+ (only alfanumerics and space)

@KK, it is an example of 'database thinking' - If I enter A.S. as my name, I do not like it when a letter comes with S.A. because someone thinks that Surname precedes Name (or vice versa). So, it is not a shame to have 1 field for the whatever user decided to submit.
Yes, I agree with your observation @trendoman.
Thankfully, regex helps out in most cases; if not, creating a new validator that suits the use-case is not too difficult (it is regular PHP function).
Thanks @trendoman. Will try it out.
6 posts Page 1 of 1