Support

Account

Home Forums ACF PRO Fire Validation Manually

Solving

Fire Validation Manually

  • I have some code that works in ACF 4 that would fire validation via JS. It looked like the following:

    acf.validation.run();
    if (acf.validation.status){
     //run custom code
    }

    Can anyone tell me how to modify this code for ACF Pro 5? When I attempt to run this, I receive an error saying that acf.validation.run is not a function.

    Hoping there is a quick answer for this.

  • @acf-support I don’t seem to see any code there that triggers validation to be run.

  • Hi @ekazda

    I’m sorry I thought you wanted to modify the errors.

    ACF 5 uses a different method that ACF 4. You can trigger the validation by using this code:

    acf.validation.fetch( $('form.acf-form') );

    But I’m not sure if it is what you want.

    I hope this helps.

  • Hello James,
    In the admin I have created a new button next to publish button,
    say MyCustom button,
    on click on that button I wanted ACF validation to take place,
    hence I have made a jQuery function
    $(‘#MyCustom’).click(function(e){
    acf.validation.fetch( $(‘#post’) );
    });

    It works like a charm when there is a validation missing,
    But when there are no validation error in the form
    then then it submits the form.
    Note that my intension is not to submit the form and hence I created another button called MyCustom,
    I want this because I want to perform some actions before submitting but after validation state.

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.