Rules For Textfield That Only Accepts Letters

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?

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.

You can use this in model rules




array('username,name','match' ,'pattern'=>'/^[A-Za-z_]+$/u'),



thanks

oh so that’s it, Thank You