How to enable Ajax form validation

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.

If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.

Recommended Posts:


Prem Tiwari

An engineer by profession and a passionate blogger by heart. Founder of FreeWebMentor.com (A Programming blog for beginners), Tech Speaker at various forums. A part from this he is an open source enthusiast, WordPress Lover, Blogger, SEO, and Growth Strategic.


Article Tags: ,

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.