• Resolved plykite

    (@plykite)


    Hello,
    How can i do to input only 5 numbers in the zip code field ? (i did this field using adress the field with select only zip code)
    Comment faire pour ne pouvoir saisir que 5 chiffres dans la zone code postal ? (jel’ai fait en utilisant le chanp de type adresse en ne sélectionnant que le code postal)

    Merci

    Pascal

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Plugin Support Laura – WPMU DEV Support

    (@wpmudev-support8)

    Hi @plykite

    It’s not possible out of the box but can be done with a bit of custom code. You can add this code to the site as “MU Plugin”:

    – create an empty file with .php extension (e.g. forminator-limit-zip-code.php)
    – copy and paste this code into it

    <?php
    /**
    * Plugin Name: [Forminator Pro] WPMU DEV Customization.
    * Description: Limits Forminator Text field under max length 5
    * Author: @ WPMUDEV
    * Author URI: https://premium.wpmudev.org/
    */
    add_action('wp_footer', 'custom_length_snippet');
    function custom_length_snippet() {?>
    	<script>
        	document.querySelector('#forminator-field-text-2').setAttribute("maxlength", 5)
    </script>
    <?php}

    Mote: In this line you’ll have to adjust the field ID

    document.querySelector('#forminator-field-text-2').setAttribute("maxlength", 5)

    – save the file and upload it to the “/wp-content/mu-plugins” folder of your WordPress installation; if there’s no “mu-plugins” folder right inside “wp-content” yet, just create an empty one first.

    It should work out of the box if field ID matches the field on the form, though you may need to clear cache on your site/server first.

    Best regards,
    Adam

Viewing 1 replies (of 1 total)

The topic ‘zip code / code postal’ is closed to new replies.