Check the amount of characters in a string function

<?php
//check the amount of characters in a string function
Function CheckNoChars($strText)
{
//check for between 6 and 12 characters
if (eregi(“^.{6,12}$” , $strText))
return true;
else
return false;
}
?>
<?php
//test the function
$str1 = “mypasswordistoolong”;
if (CheckNoChars($str1))
//if its OK display this message
echo “this has the correct number of characters”;
//if its not OK display this one instead
else
echo “incorrect number of characters”;
?>

LEAVE A REPLY

Please enter your comment!
Please enter your name here

*