0

When using int-tel-input jQuery plugin, one sometimes needs to reset the placeholder to default. Is there a method like :

$('input').intlTelInput('setPlaceholder', 'myDefaultPlaceholder' );

which should be called after :

$('input').intlTelInput('setCountry', 'myDefaultCountry' );
$('input').intlTelInput('setPlaceholderNumberType', 'MOBILE' );

The workaround I think of is :

$('input').val( "" );
$('input').attr( "placeholder", "defaultPlaceholder" );
$('input').intlTelInput('setCountry', 'myDefaultCountry' );
Stephen Adelakun
  • 784
  • 2
  • 7
  • 24

1 Answers1

1

Oh mine. After much trial-and-error, I just discovered that the method I was looking for is redundant after all. First setting the value of the input element to empty string and then calling 'setCountry' api method did the trick.

$('input').val( "" );
$('input').intlTelInput('setCountry', 'myDefaultCountry' );

What stopped if from working the first time was the space I inserted in the value like so $('input').val( " " ); instead of $('input').val( "" ); And since the plugin found a blank space as the value of the input element, the placeholder did not show up.

Just in case anyone may find this helpful.

Stephen Adelakun
  • 784
  • 2
  • 7
  • 24