• Resolved dedrago

    (@dedrago)


    Is there a way how I could add format masks? Currently I can do it with another plugin. But it requires to check what country is selected in order to add class which creates mask. Eg. .phone_us for us. .phone for everything else. Thank you.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor damiarita

    (@damiarita)

    Hi,

    From your text I understand you need to change the class each time a country is selected. Am I right?

    It would be impossible to add a GUI to the plugin that allows all the pissibilities.

    The best thing is that you add a JS function that does that and callit when the country change event is fired.

    You have all the details of the event at https://github.com/jackocnr/intl-tel-input/blob/master/README.md#events

    All the telephone inputs the plugin creates have the class ‘wpcf7-intl-tel’. So, you can use that as selector.

    Hope it helps!

    Thread Starter dedrago

    (@dedrago)

    Thank you for the fast reply! Could you please give me an example how to create a condition. If country is US set .phone_us class to the input field. Thank you very much!

    Plugin Contributor damiarita

    (@damiarita)

    Hi,

    I would add this piece of JS:

    jQuery('.wpcf7-intl-tel').on('countrychange', function(e, countryData){
     const usClass='phone_us ';
     if(countryData.iso2==='us'){
      jQuery(e.target).addClass(usClass);
     }
     else{
      jQuery(e.target).removeClass(usClass);
     }
    });
    Thread Starter dedrago

    (@dedrago)

    Yeah! This one does the trick! Thank you Damiarita!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Input mask’ is closed to new replies.