Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

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

Packages

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.

Behavior

Save Automatically?

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.

HTML

              
                <html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
  <script src="https://cdn.jsdelivr.net/jquery.validation/1.15.0/jquery.validate.min.js"></script>
  <script src="https://cdn.jsdelivr.net/jquery.validation/1.15.0/additional-methods.min.js"></script>
  <link rel="stylesheet" type="text/css" href="https://www.bartenderschool.in/wp-content/themes/ebs-v2/css/intlTelInput.css" />
  <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/8.4.5/js/intlTelInput.min.js"></script>
  <script type="text/javascript" src="https://www.bartenderschool.in/wp-content/themes/ebs-v2/js/vendor/utils.js"></script>
  <script type="text/javascript" src="https://www.bartenderschool.in/wp-content/themes/ebs-v2/js/tracking.js"></script>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
  <title>Document</title>
</head>
<body>
  <form id="form_top" accept-charset="UTF-8" enctype="multipart/form-data" method="POST" data-form-name="Instapage">

    <div class="input-container">
      <i class="fa"></i>
      <input type="text" id="firstname" name="firstname" placeholder="First name" 
        data-msg="Please enter your first name" tabindex="1" autocomplete="given-name">
    </div>

    <div class="input-container">
      <i class="fa"></i>
      <input type="text" id="lastname" name="lastname" placeholder="Last name" data-msg="Please enter your last name" 
        tabindex="2" autocomplete="family-name"/>
    </div>

    <div class="input-container">
      <i class="fa"></i>
      <input type="email" type="email" id="email" name="email" placeholder="Email" tabindex="3"
        data-msg-required="Please enter your email"
        data-msg-format="Please enter a valid email"
        data-msg-domain="Email domain don‘t exist" 
        autocomplete="email"
      />
    </div>
    
    <div class="input-container">
      <i class="fa"></i>
      <input type="tel" name="itl-phone" id="itl-phone" class="itl-phone" tabindex="4"
        data-msg-required="Please enter your phonenumber"
        data-msg-valid="Please enter a valid phonenumber" 
       /> 
      <label for="itl-phone" generated="true" class="error"></label>
    </div>

    <input type="hidden" name="itlPhoneFull" class="itlPhoneFull">

    <div class="submit-container">
      <button type="submit" name="formSubmit" value="Download Brochure" tabindex="5">Download Brochure</button>
    </div>
  </form>
 </body>
</html>
              
            
!

CSS

              
                body{
  max-width: 430px;
  height: 500px;
  margin-left: 100px;
  margin-top: 50px;
  background-image: url("//storage.googleapis.com/instapage-user-media/a72e0636/16866501-0-06brochure.jpg");
  background-position: -300px;
}  

  /* reset */
  legend {
    padding: 0;
    display: table;
  }
  fieldset {
    border: 0;
    padding: 0.01em 0 0 0;
    margin: 0;
    min-width: 0;
  }
  body:not(:-moz-handler-blocked) fieldset {
    display: table-cell;
  }
  textarea:focus, input:focus, div:focus{
    outline: none;
  }

  /* Form styles */
  $error-color: red;
  $text-color: #eee;
  $success-color: #2cc16f;
  $background-color: #eee;
  $border-color: #d2d2d2;

  /* Centering icons vertically */  
  $inputHeight: 44px;
  $inputFaSize: 20px;
  $submitFaSize: 20px;

  /* Placeholder color on invalid */
  input.error{color: $error-color;}
  .error::-webkit-input-placeholder { color: $error-color; }
  .error:-moz-placeholder { color: $error-color; }
  .error::-moz-placeholder { color: $error-color; }
  .error:-ms-input-placeholder { color: $error-color; }

  /* Remove yellow background on chrome after autofill */
  input:-webkit-autofill {
    -webkit-box-shadow: 0 0 0 30px $background-color inset;
  }

  .input-container{
    height: 70px;
    text-align: left;
    position: relative;
    i{
      position: absolute;
      z-index: 1;
      font-size: $inputFaSize;
      top: ($inputHeight - $inputFaSize) / 2;
      right: ($inputHeight - $submitFaSize) / 2;
      display: none;
    }
    i.valid{
      color: $success-color;
      display: inline-block;
    }
    i.error{
      color: $error-color;
      display: inline-block;
    }
    input[type="text"], input[type="email"], input[type="tel"], div.intl-tel-input.allow-dropdown {
      height: $inputHeight;
      line-height: $inputHeight;
      box-sizing: border-box;
      padding: 0 10px;
      margin: 0;
      background: $background-color;
      background-repeat:  no-repeat;
      background-position: right 8px center;
      border: 1px solid $border-color;
      border-radius:5px;
      font-size: 14px;
      font-weight: 300;
      font-family: "Lato", sans serif;
      width: 100%;
      &.error{
        border-color: $error-color;
      }
    }
    label.error{
      color: lighten($error-color, 10%);
      padding-left: 20px;
    }
  }

  p.phone-help{
    color: $text-color;
    margin-bottom: 5px;
  }

  .intl-tel-input{
    &.allow-dropdown{
      input[type=tel].itl-phone{
        background: transparent;
        height: $inputHeight - 2;
        padding-left: 70px;
        padding-right: 0;
        border: none;
      }
      &.separate-dial-code{
        .selected-flag{
          background: none;
        }
        .flag-container{
          padding: 0;
        }
      }
      .flag-container{
        border-right:1px solid #b4b4b4;
        padding: 10px;
        z-index: 10;
      }
    }
  }
  .iti-mobile .intl-tel-input.iti-container {
    z-index: 12000000;
  }
  .iti-flag {
    background-image: url("https://www.bartenderschool.in/wp-content/themes/ebs-v2/images/min/flags.png") !important;
  }

  .submit-container{
    position: relative;
    width: 250px;
    height: $inputHeight;
    margin: 0 auto;
    button[type="submit"]{
      -webkit-appearance: none;
      background-color: #2cc16f;
      color: #ffffff;
      left: 0px;
      height: $inputHeight;
      width: 100%;
      font-size: 15px;
      font-weight: 400;
      font-family: "Lato", sans serif;
      line-height: $inputHeight;
      box-sizing: border-box;
      border-radius: $inputHeight / 2;
      &:hover{
        background-color: #2aba6b;
        border-radius: $inputHeight / 2;
        -webkit-appearance: none;
      }
    }
    i{
      position: absolute;
      right: ($inputHeight - $submitFaSize) / 2;
      font-size: $submitFaSize;
      top: ($inputHeight - $submitFaSize) / 2;
    }
  }

  button[disabled="disabled"], button[disabled="disabled"]:hover{
    background-color: #9a9a98;
    cursor: not-allowed;
  }

  @media only screen and (max-width: 640px){
    button[type="submit"]{
      -webkit-appearance: none;
      width: 100%;
    }
  }

  @media only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (min--moz-device-pixel-ratio: 2),
  only screen and (-o-min-device-pixel-ratio: 2 / 1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
    .iti-flag {
      background-image: url("https://www.bartenderschool.in/wp-content/themes/ebs-v2/images/min/flags@2x.png") !important;
    }
  }

  @media screen and (max-device-width : 736px) and (-webkit-min-device-pixel-ratio:2) { 
    select,
    textarea,
    input,
    input:focus,
    input:hover {
      font-size: 16px !important;
    }
  }
              
            
!

JS

              
                $(document).ready(function(){
  /* form_top / form_bottom */

  $('.itl-phone').intlTelInput({
    autoPlaceholder: true,
    preferredCountries: ["au","be","ch","de","dk","es","fi","fr","gb","ie","it","nl","no","se","us","pl","pt","za"],
    separateDialCode: false,
    initialCountry: "gb",
  });
  
  $('.itl-phone').attr('autocomplete', 'tel');

  /*Keep watching the inputs for change (browser autofill fix)*/
  form_top = {};
  setInterval(function() {
    $('#form_top input:visible').each(function() {
      var $elem = $(this);
      if ($elem.val() != form_top[$elem[0].name]){
        form_top[$elem[0].name] = $elem.val();
        $elem.change();
      }
    })
  }, 250);

  form_bottom = {};
  setInterval(function() {
    $('#form_bottom input:visible').each(function() {
      var $elem = $(this);
      if ($elem.val() != form_top[$elem[0].name]){
        form_bottom[$elem[0].name] = $elem.val();
        $elem.change();
      }
    })
  }, 250);

  $('input').change(function(){
    if( $(this).hasClass('error') || $(this).hasClass('valid')){
      updatePhoneContainer( $(this) );
    };
  });

  $('input').blur(function(){
    updatePhoneContainer( $(this) );
  });

  $('.itl-phone').keyup(function(e){
    if( $(this).hasClass('error') || $(this).hasClass('valid') ){
      updatePhoneContainer($(this));
    };
  });

  function updatePhoneContainer($element){
    var valid = $element.valid();
    if( $element.hasClass('itl-phone')){
      $element.closest('form').find('.intl-tel-input').addClass( valid ? 'valid':'error').removeClass( valid ? 'error':'valid');
    };
  };

  /*Helper function to set validation messages from data-msg on inputs*/
  function getMsg(selector, context, type) {
    return $(selector, context).attr(type);
  };

  $('form').each(function(){
    var $this = this;
    var validIcon = 'fa-check-circle-o';
    var errorIcon = 'fa-times-circle-o';
    function toggleValid(valid, $element){
      $container = $($element).closest('.input-container');
      var iconClasses = 'fa ' + (valid ? validIcon + ' valid' : errorIcon + ' error');
      $container.find('i').attr('class','').addClass( iconClasses );
      $element.addClass( valid ? 'valid' : 'error' ).removeClass( !valid ? 'valid' : 'error' );
    };
    var validator = $(this).validate({
      ignore: ":hidden",
      highlight: function(element){toggleValid(false, $(element))},
      unhighlight: function(element){toggleValid(true, $(element))},
      rules: {
        firstname: {
          required: true,
        },
        lastname: {
          required: true,
        },
        email: {
          required: true,
          email: true,
          RFC2822Email: true,
        },
        countrycode: {
          required: true,
        },
        'itl-phone': {
          required: true,
          phone_valid: true,
        }
      },
      messages: {
        firstname: getMsg('input[name="firstname"]', $this, 'data-msg'),
        lastname: getMsg('input[name="lastname"]', $this, 'data-msg'),
        email: {
          required: getMsg('input[name="email"]', $this, 'data-msg-required'),
          email: getMsg('input[name="email"]', $this, 'data-msg-format'),
          RFC2822Email: getMsg('input[name="email"]', $this, 'data-msg-format'),
          remote: getMsg('input[name="email"]', $this, 'data-msg-domain'),
        },
        'itl-phone': {
          required: getMsg('.itl-phone', $this, 'data-msg-required'),
          phone_valid: getMsg('.itl-phone', $this, 'data-msg-valid'),
        },
      },
      submitHandler: function(form) {
        $(form).find('.loader').show();
        $(form).find('button[type="submit"]').html('Please wait.. <i class="fa fa-spinner fa-pulse"></i>');
        $(form).find('.itlPhoneFull').val( $(form).find('.itl-phone').intlTelInput("getNumber") );
        validator.resetForm();
        return false;
      },
      invalidHandler: function(event, validator) {
        if ( $("#itl-phone").intlTelInput("getValidationError") == 0 && !$("#itl-phone").intlTelInput("isValidNumber") ) {
          var $inputs = $(':input', $this);
          var values = {};
          var i = 1;
          $inputs.each(function() {
            if ( $(this).val() ){
              /* switch on itl-phone here */
              values[this.name] = $(this).val();
            };
            if ( $.inArray( $(this)[0].name ["firstname","lastname","email","itl-phone"] )) {
              _paq.push(['setCustomVariable', i, $(this)[0].name, $(this)[0].value, "page"]);
              i++
            };
          });
          _paq.push(['trackEvent', 'Form', 'Instapage', 'Invalid']);
          $.post( "{{ site_url }}/wp-content/themes/ebs-v2/check.php", { valid: 0, data: JSON.stringify(values) } );
        }
      },
    });
  });

  jQuery.validator.addMethod("RFC2822Email", function(value, element) {
    //value = value.toLowerCase();
    return this.optional( element ) || ( /(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])/.test( value ) );
  });

  jQuery.validator.addMethod("phone_possible", function(value, element) {
    var form = $(element).parents('form:first');
    var error = $("#itl-phone", form).intlTelInput("getValidationError");
    return error == 0;
  });

  jQuery.validator.addMethod("phone_valid", function(value, element) {
    var form = $(element).parents('form:first');
    return $(element).intlTelInput("isValidNumber");
  });

  jQuery('input[name="js"]').val('1');
  jQuery('input[name="timezonediff"]').val(function(){
    var d, offset, sign, hours, minutes, result;
    d	= new Date();
    offset = - d.getTimezoneOffset() * 60;
    sign = offset > 0 ? '+' : '-';
    offset = offset > 0 ? offset : -offset;
    hours = parseInt( offset / 3600 ) % 24;
    minutes = parseInt( offset / 60 ) % 60;
    result = sign + (hours < 10 ? "0" + hours : hours) + ":" + (minutes < 10 ? "0" + minutes : minutes);
    return result;
  });
});
              
            
!
999px

Console