I want to check if form is valid or not on client side. How can I do it?
In yii1.x we had option “afterValidate”. But on yii2 I can’t find any option like that. So I am using
$("#form").on("submit",function(e){
e.preventDefault();
// How to check if form is valid?<img src='http://www.yiiframework.com/forum/public/style_emoticons/default/huh.gif' class='bbc_emoticon' alt='???' />
});
Also, Yii 2 has client validation on by default, I believe it creates Javascript rules on the fly based on your validation methods; however if you have custom methods then it probably wouldn’t include those.
Obviously make sure you’re still validating it on the server side as well.
On top of that there is also AJAX Validation for validation that has to be done server side, but you want to make it act like client side validation.