input field validation

How do we add email input field validation in a form so that it accepts only valid email address?

In which file we add the validation code?

In the basic application contact-us form, this validation is already there, but it is not obvious that where does its code exist.

I found that its code is there in the corresponding model file.I am able to add this email validation.

But I want to know how do we add validation that password and confirm_password input data match.

Maybe this will help you:

http://www.yiiframework.com/wiki/56/

Use the compare validator.