tarzanit
(Junglist)
1
Hi All!
I want to check if a username or an email is available when users register an account.
Now the php code like this can do with a form submitted entirely:
$form = new RegistrationForm;
$form->attributes = $_POST['RegistrationForm'];//array('username'=>'aaaa','password'=>'bbbb','email'=>'cccc@ccc.com')
if($form->validate())
{
//...
}else{
//list all error messages
}
How can I validate only one attribute at a time?
Thank you in advance.
rookie84
(Lifeline Is)
2
How do you want to validate?
$form = new RegistrationForm;
$form->attributes = $_POST[‘RegistrationForm’];//array(‘username’=>‘aaaa’,‘password’=>‘bbbb’,‘email’=>‘cccc@ccc.com’)
You may try:
//This validates only the username
if ($form->validate(array(‘username’))) {
}
This is for validating a single attribute.