Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                <!-- Load Emoji One Support -->
<script src=""></script>
<link rel="stylesheet" href=""/>
<!-- Actual content -->
<p id="errorMessage" style="display: none;">
  THIS DEMO WORKS ONLY IN  BROWSER THAT SUPPORTS FETCH. Adjust the fetch call to use a different AJAX HTTP request to use it in other browsers.
<h1>Phone Validation Example</h1>
  <label for="phoneNumber">Phone Number</label>
  <input class="phone-input" id="phoneNumber" name="phoneNumber" type="tel" autocomplete="tel" required value="+14157012311" placeholder="Use international format">
  <span class="valid-indicator">
    <img class="emojione valid" alt="✅" title=":white_check_mark:" src=""/>
    <img class="emojione invalid" alt="❎" title=":negative_squared_cross_mark:" src=""/>
  <span class="country-code"></span>


                html, body {
  padding: 0;
  margin: 0;
  width: 100%;
  height: 100%;
  box-sizing: border-box;

body {
  font-family: ‘Trebuchet MS’, Helvetica, sans-serif;
  font-weight: 200;
  color: #333;
  border-top: 5px solid #F22F46;
  font-size: 25px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;

h1 {
  font-weight: 100;
  color: #0D122B;

input {
  position: relative;
  font-size: 1em;
  padding: 10px;
  border: 2px solid #efefef;

/* Form specific styles */

.phone-input + .valid-indicator > .valid {
  display: initial;

.phone-input + .valid-indicator > .invalid {
  display: none;

.phone-input:invalid + .valid-indicator > .valid {
  display: none;

.phone-input:invalid + .valid-indicator > .invalid {
  display: initial;

.country-code[data-loading] > img {
  animation-name: rotatingEmoji;
  animation-duration: 1s;
  animation-iteration-count: infinite;
  animation-timing-function: linear;

@keyframes rotatingEmoji {
  from { transform: rotateZ(0deg) scaleX(-1); }
  to { transform: rotateZ(360deg) scaleX(-1); }


                if (typeof fetch !== 'function') {
  document.getElementById('errorMessage').style.display = 'block';

var phoneNumberInput = document.getElementById('phoneNumber');
var countryFlag = document.querySelector('.country-code');
var lastTimeout = undefined;

phoneNumberInput.addEventListener('keyup', keyListener);

function keyListener() {
  if (lastTimeout) {
  if (phoneNumberInput.value.length > 4) {
    lastTimeout = setTimeout(verifyNumber, 300);

function verifyNumber() {
  var currentNumber = phoneNumberInput.value;
  fetch('' + currentNumber)
    .then(function (response) {
      if (!response.ok) {
        throw new Error('Something went wrong with the HTTP call.');
      return response.json();
    .then(function (data) {  
      if (data.valid) {
        countryFlag.innerHTML = emojione.toImage(':flag_' + + ':');
      } else {
        phoneNumberInput.setCustomValidity('Invalid phone number');
    .catch(function (err) {
      phoneNumberInput.setCustomValidity('Could not verify number');

function showLoading() {
  countryFlag.setAttribute('data-loading', true);
  countryFlag.innerHTML = emojione.toImage(':arrows_counterclockwise:');

function stopLoading() {
  countryFlag.innerHTML = '';