Jump to content

[SOLVED] Easy question


boney alex

Recommended Posts

Ive got this function which checks the username contains only letters and numbers and is between 6-12 characters long. How do I change this function to only allow letters and spaces and be of any length?

<?
function usernamecheck($username) 
{
if (eregi ("^[[:alnum:]]{6,12}$", $username)) 
{
return true;
} 
else 
{
return false;
}
}
?>

 

Cheers

Link to comment
https://forums.phpfreaks.com/topic/48789-solved-easy-question/
Share on other sites

Ive got this function which checks the username contains only letters and numbers and is between 6-12 characters long. How do I change this function to only allow letters and spaces and be of any length?

<?
function usernamecheck($username) 
{
if (eregi ("^[[:alnum:]]{6,12}$", $username)) 
{
return true;
} 
else 
{
return false;
}
}
?>

 

Cheers

 

Try something like:

<?php

function usernamecheck($username){
   if(eregi("^[a-zA-Z ]*$", $username)){
      return true;
   }

   else{
      return false;
   }
}

?>

Link to comment
https://forums.phpfreaks.com/topic/48789-solved-easy-question/#findComment-239160
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.