I have AJAX form [gravityform id="2" title="false" description="false" ajax="true" required_legend="false"]
I need to run a js function after submitting a form when the form shows the message gform_validation_errors
. Is it posiable?
I need something like that -
$(document).on('gform_post_validation', function(formId, isValid) {
if (formId === 2) {
console.log("Form ID 2 validation result: " + isValid);
$('.gfield_contains_required input').each(function() {
let $label = $(this).closest('.gfield_contains_required').find('label');
if ($(this).val().trim() === '') {
$label.addClass('hidden');
} else {
$label.removeClass('hidden');
}
});
}
});