How to enable Ajax form validation

| Last Updated: | In: Yii framework


Form validation ensures that each and every field in the form has been filled in the required way. No further prelude is required to this topic as Developers would be well aware about the purpose and function of form validations. In one of my bygone projects, I had a claim to validate a form with AJAX which I did successfully.

I found less online reference while trying to achieve the purpose, hence thought of leaving a path to others so that this can be used as a reference, The following steps should be used to validate your Yii form using AJAX.

Declaring beginWidget()

Matching error function in form element

Generating Response

Validate rule in model

When we use $form->error(), Yii includes hidden div after your form element.


About: Prem Tiwari

Prem Tiwari is the founder of freewebmentor.com and is a professional developer who has vast experience in PHP and open source technologies. Apart from this, he is a blogger by hobby and also he has been a regular speaker of WordPress sessions in various IT Companies.


You may also like:


,