jr_jags
(Jr Jagolino)
January 24, 2013, 3:26pm
1
Good Day,
I have thisproblem that I want to make the accepted inputon my textField is alphabets only so in my rules function on my Model class i wrote
array(‘username, name’,‘CRegularExpressionValidator’, ‘pattern’=>’[a-z\s]{3,}’),
It returns error when I Input a numerical field but when I try to input a word, It still returns an error, Why is this happening?
Is their another way I can set up a letterOnly rules?
seenivasan
(Chellamnivas)
January 24, 2013, 4:32pm
2
Dear FRIEND
Kindly check the following.
public function rules()
{
return array(
array('name,username','required'),
array('name,username','CRegularExpressionValidator', 'pattern'=>'/^[a-zA-z]{3,}$/','message'=>"{attribute} should contain only letters and should have atleast 3 of them."),
);
}
Regards.
ani
(Aneesh)
January 24, 2013, 4:45pm
3
You can use this in model rules
array('username,name','match' ,'pattern'=>'/^[A-Za-z_]+$/u'),
thanks
jr_jags
(Jr Jagolino)
January 24, 2013, 10:13pm
4
seenivasan:
Dear FRIEND
Kindly check the following.
public function rules()
{
return array(
array('name,username','required'),
array('name,username','CRegularExpressionValidator', 'pattern'=>'/^[a-zA-z]{3,}$/','message'=>"{attribute} should contain only letters and should have atleast 3 of them."),
);
}
Regards.
oh so that’s it, Thank You