• Resolved Ericmuc

    (@ericmuc)


    I have a question regarding the language of validation messages.

    I have a acf form in the woocommerce cart with some custom code in functions.php. I have let added a PDF download and PDF E-Mail. The download creates a PDF with data from the acf form, all without validation, because it shall be possible to create a PDF only with the products and without any acf fields.

    But with the PDF E-Mail the user must add his e-mail address and this is coded in functions.php ike this:

    add_action('wp_footer','custom_javascript');
    function custom_javascript(){?>
    <script type="text/javascript">
        jQuery(document).ready(function(){
            jQuery(".wc-proceed-to-checkout .cart-pdf-button").click(function(e){
                var $this = jQuery('.acf-form');
                var pdfaction = jQuery(this).data('action');
                if(pdfaction == 'email' && jQuery('.acf-field-email input').val()==''){
                    jQuery('.acf-field-email input').attr('required','required');
                    e.preventDefault();
                }else{
                    jQuery('.acf-field-email input').removeAttr('required');
                }
                pdfaction = pdfaction.trim();
                if ($this.find('#pdfaction').length) {
                  $this.find('#pdfaction').val(pdfaction);
                } else {
                  $this.append('<input type="hidden" id="pdfaction" name="pdfaction" value="'+pdfaction+'" />');
                }
    
                //jQuery('.acf-form').append('<input type="hidden" name="pdfaction" value="'+jQuery(this).text()+'">');
                jQuery(".acf-form-submit button").click();
                e.preventDefault();
            });
        });
    </script>
    <?php }

    It works. But the validation message is in the browser language (here German), not in the language of the wordpress system (English). Please see this image (I set name in acf form as required to see the difference):

    Name = set in acf form as required
    E-Mail = set with functions.php as required

    Please see image hier: https://iqbox.cloud/index.php/s/mn23ggd5LR9WNSH

    So my question: what can I do to get the validation message set by requirement by functions.php also in English language?

    Thank you und best regards

Viewing 1 replies (of 1 total)
  • Plugin Author fabianlindfors

    (@fabianlindfors)

    Hi, Eric!

    As you have noticed, when using the “required” attribute, ACF will automatically use the error provided by the browser instead of an error generated server-side.

    This feature is implemented in ACF so unfortunately, I can’t offer much help. I would recommend reaching out to ACF support and see if they have some nifty filter or similar for changing the error message through Javascript.

    All the best!

Viewing 1 replies (of 1 total)
  • The topic ‘Language validation message’ is closed to new replies.