How to reinitialise validation after custom AJAX field replacement

Proven Method to Reinitialize Form Validation After AJAX Field Replacement

Overview

When using AJAX to replace a form field, validation rules may be lost. To restore them, call three initialization functions after the field is replaced. This solution ensures form validation works correctly post-AJAX updates.

When you use a reload event in a field to reload another field, Chronoforms sorts out re-initialising the validation for you. But if for whatever reason you need to use AJAX to replace a field on your own, it loses its validation rules. Just put the following in your AJAX function AFTER the field is replaced.

$.G2.forms.initializeFeatures(jQuery('.ui.form'));​
$.G2.forms.initializeEvents(jQuery('.ui.form'));​
$.G2.forms.initializeForm(jQuery('.ui.form'));

With thanks to healyhatman.

You may also like:

Comments:

You need to login to be able to post a comment.