Recently i have been working on Yii 2 for one of my clients. The application relies heavily on Ajax for loading different components and forms. Since there were forms, I had to use validation as well.
Yii 2 has made validation very simple. The server side validation worked perfectly, almost out of the box. I also had to add client side validation and despite everything being in order, the forms were not showing validation errors on input change.
So, all that is needed to make client side validation work on an ajax loaded page is to enable client validation like so:
$form = ActiveForm::begin([
'id' => 'contact-form',
'enableClientValidation' => true,
And then rendering the form view like so:
Latest posts by alexey (see all)
- Zend Soap NULL Reponse - August 29, 2018
- Quick Facts About WooCommerce - April 25, 2018
- WordPress stuck on a “Too many redirects” error loop when using SSL - January 17, 2018