Page 1 of 1
regex: must have atleast 1 digit, how?
Posted: Tue May 11, 2004 7:47 am
by qads
Code: Select all
<?php
if(!ereg("[a-zA-Z0-9]{5,15}", $password))
{
$form->error[] = 'Your password is invalid, password must be letters and numbers only, must have atleast 1 digit and should be 6 to 15 characters in length';
}
?>
the above, checks to see if the password is 6 to 15 chars in length, if it is numbers and letters, but how can i make it to check if it has atleast 1 digit in it?

.
thanks
- Qads -
Posted: Tue May 11, 2004 8:55 am
by Wayne
probably not want you want to hear .... but why not just ....
Code: Select all
if(! ( ereg("[a-zA-Z0-9]{5,15}", $password) && ereg("[0-9]+", $password) ) )
Posted: Tue May 11, 2004 9:06 am
by qads
thats how i have it atm, just wanted to know, call it a learning thing

.