Back

Example: Invalid Key

Use the custom invalidkey event to flash the input red. To test it, focus the input and type an invalid character e.g. a letter.

Markup

<input id="phone" type="tel">

Code

var input = $("#phone");

input.intlTelInput({
  utilsScript: "../../lib/libphonenumber/build/utils.js" // just for formatting/placeholders etc
});

input.on("invalidkey", function() {
  input.addClass("flash");
  setTimeout(function() {
    input.removeClass("flash");
  }, 100);
});

Result