ActiveForm multi submit in ajax (client validation)

Hi guys,

in my page I have a general form, and secondary one that I’d like to use to append some hidden input in my main form.

Everything works well in the first submit (client validation, and action).

On the next submit client validation not work.

How I can "reset" the form after first submit so to reuse it, especially the client validation.

Could you show us a simplified code that illustrates your issue, please ?

I don’t get what you are doing.

Hi softark,

the code is very bigger.

It is simple, in a page I want to use a form to receive user input that I will use to build an html fragment that I will append to the DOM with jquery without refreshing the page.

For this I create an ActiveForm with Ajax submit. If it is ok, I’d like to reset form to permit user adding another fragment.

The problem is that client validation work only at the first time. It is like the form store the first validation results.

I tried to use this method


but validation continue to not work

A client validation is actually a customized javascript function for an input field. It is constructed on the server side when the input is created, depending on the validation rules of the field. You can check the html output and will find some javascript snippets that execute the client validations.

I guess your added html fragments don’t have those javascript snippets for the client validation.

thanks, the problem was in the form, not in the input appended in html fragment

I used a wrong code for ajax submit because I use .submit concatenated to event "beforeSubmit" and this sign the yiiActiveForm "validated" and on the second submit validation was skipped.

 $('form#add-tpoint').on('beforeSubmit', function(e) { ... }).submit()