Jump to content

[SOLVED] Require Letter


sstangle73

Recommended Posts

Define a regular expression pattern for the user name.

"/[a-z]+[0-9]*/i"

This would match anything with minimum 1 letter and 0 or more numbers. It is case-insensitive, but it can be changed to match anything you think of.

 

if(preg_match("/[a-z]+[0-9]*/i",$input)){
     //username is ok
}

 

Regular expressions can be difficult to get a hang of at first, but it is well worth the time and effort. In my opinion anyway.

 

http://us3.php.net/manual/en/reference.pcre.pattern.syntax.php

Link to comment
https://forums.phpfreaks.com/topic/65460-solved-require-letter/#findComment-327374
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.