Nandini Posted January 20, 2009 Share Posted January 20, 2009 Hi i am designing php aurthentication script. I want to validate username field while create useraccount. I want to validate username as same as gmail username. That means only letters (a-z), numbers (0-9), and periods (.) are allowed. and username cannot contain consecutive periods (.), like this. i have used the following line of code. But i did not get complete solution. eif(!eregi("^[a-z0-9.]{4,16}$",$_POST['username'])) { $errmsg='Only letters (a-z), numbers (0-9), and periods (.) are allowed for username.'; } Can anyone give me solution Link to comment https://forums.phpfreaks.com/topic/141577-php-username-validations/ Share on other sites More sharing options...
gevans Posted January 20, 2009 Share Posted January 20, 2009 You need to escape the '.' character, so try the following; eregi("^[a-z0-9\.]{4,16}$",$_POST['username']) Link to comment https://forums.phpfreaks.com/topic/141577-php-username-validations/#findComment-741055 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.