- The username should contain only alphabatic chars (a-z) up to 25 chars.
- The first and the last space should be removed.
- The username can be more then 1 word, not a limit for how many words the name counts
So the regex I am using now is almost valid, except that a username with 3 words or more isn't valid. And this should be valid.
Valid names can be:
- Dennis
- Dennis is
- Dennis is cool
- Dennis is the coolest
- etc.. up to 25 chars because this is the max length.
This is the current regex I am using:
var pattern = /^[a-z\u00C0-\u01FF]+([\s\.\-\']?[a-z\u00C0-\u01FF]+)? $/i;
if (pattern.exec(uname) == null)
{
alert('Invalid name');
return false;
}
So how to adjust the regex to make it work for more words then 2 with a maximum length of 25 chars?
Aucun commentaire:
Enregistrer un commentaire