how to make a input validation

I make a registration form, and my problem is I don’t know how to trap the users inputted data

and my question is

how to make a input validation like this ??? its i need to code it manually or something in yii i need to call to validate the inputted data in customize registration form??

thanks a lot in advance :lol: :lol: :lol:

Read documentation first

for input validation, you need to define validation rules in your model.

See your model, there is a rules function, in which you can define rules as you need for input value.

eg. -


* @return array validation rules for model attributes.


   public function rules(){

      array('id, name, username, email', 'required'),

      array('email', 'email', 'message'=>"The email isn't correct."),

      array('email', 'unique', 'message' => 'Email address already exist, please enter another email address.'),


More help - Model rules validation

All U need is to set rules in your model class.

Check this Model.rules

Thanks a lot for helping me hmpp… i got a problem again when I try to put required why I am getting error :unsure:

please check the attachment sir =)

I resolve this by removing this

, ‘length’, ‘max’=>50

but i don’t know why its work after removing that code? :unsure: :unsure: :blink: :blink: :blink:

ah ok, I understand now don’ t put all rules in one line…

correct rule



thanks a lot ruling solve

topic close =)