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

              
                <!doctype html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>申込フォーム</title>
    <link rel="stylesheet" href="style.css">
    <script src="https://code.jquery.com/jquery-3.2.1.js" integrity="sha256-DZAnKJ/6XZ9si04Hgrsxu/8s717jcIzLy3oi35EouyE=" crossorigin="anonymous"></script>
  </head>
  <body>
    <form>
      <br>
      <div class="form form-name">
        <label>お名前 :</label>
        <input class="tooltiper nameCheck" type="text" placeholder="田中 太郎">
        <span class="tooltipMsg">名字と名前の間はスペースをあけてください</span>
      </div>
      <br>
      <div class="form form-tel">
        <label>電話番号:</label>
        <input class="tooltiper telCheck" type="text" placeholder="080-1234-5678">
        <span class="tooltipMsg">必ず入力してください</span>
      </div>
      <br>
      <div class="form form-mail">
        <label>メール :</label>
        <input class="tooltiper mailCheck" type="text" placeholder="example@gmail.com">
        <span class="tooltipMsg">メールでの連絡をご希望の方は記入してください</span>
      </div>
      <br>
      <input type="submit" value="送信する">
    </form>
    <script src="app.js"></script>
  </body>
</html>
              
            
!

CSS

              
                input:focus::placeholder {
  color: transparent;
  transition: .2s;
}
.form {
    width: 300px;
}
form span.tooltipMsg {
  position: relative;
  display: inline-block;
  margin: 1.2em 0;
  padding: 0px 10px;
  min-width: 120px;
  max-width: 100%;
  color: white;
  font-size: 12px;
  background: rgb(120, 120, 120);
  border-radius: 5px;
  box-shadow: 0px 1px 2px 0 rgb(120, 120, 120);
  z-index: 10000;
  display: none;
}
form span.tooltipMsg:before {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -15px;
  border: 8px solid transparent;
  border-top: 8px solid rgb(120, 120, 120);
}
.alert__name, .alert__tel, .alert__mail {
  font-size: 12px;
  color: rgb(219, 46, 48);
  margin-left: 75px;
}
.form-name, .form-tel, .form-mail, .form-other {
  position: relative;
}
.form-name span.tooltipMsg {
  position: absolute;
  left: 10%;
  bottom: 75%;
}
.form-tel span.tooltipMsg {
  position: absolute;
  left: 30%;
  bottom: 75%;
}
.form-mail span.tooltipMsg {
  position: absolute;
  left: 5%;
  bottom: 75%;
}

              
            
!

JS

              
                $('form .form').each(function() {
    var formVal = $(this)
    formVal.find('.tooltiper').focus(function() {
      formVal.find('.tooltipMsg').fadeIn(200)
    }) 
  })
$('.tooltiper').blur(function() {
  validation_check($(this))
  $('form').find('.tooltipMsg').fadeOut(200)
})
function validation_check(e) {
  if($("[class$='Check']")[0] === e[0]) {
    name_checker(e)
  } else if($("[class$='Check']")[1] === e[0]) {
    tel_checker(e)
  } else if($("[class$='Check']")[2] === e[0]) {
    mail_checker(e)
  }
} 
function name_checker(e) {
  if(e.val() == '') {
    create_errmsg(e, 'name', ' 名前が入力されてません')
  } else {
    $(".alert__name").prev().css('border-color', '#cccccc')
    $(".alert__name").remove()
  }
} 
function tel_checker(e) {
  var tel = e.val().replace(/[━.*‐.*―.*-.*\-.*ー.*\-]/gi,'')
  if(!tel.match(/^(0[5-9]0[0-9]{8}|0[1-9][1-9][0-9]{7})$/)) {
    create_errmsg(e, 'tel', ' 電話番号が正しくありません')
  } else {
    $(".alert__tel").prev().css('border-color', '#cccccc')
    $(".alert__tel").remove()
  } 
}
function mail_checker(e) {
  if(e.val().match(/.+@.+\..+/)==null) {
    create_errmsg(e, 'mail', ' メールアドレスが正しくありません')
  } else {
    $(".alert__mail").prev().css('border-color', '#cccccc')
    $(".alert__mail").remove()
  }
}
function create_errmsg(obj, key, msg) {
  if(!($('.alert__' + key).length)) {
    var html = '<div class="alert__' + key + '">' + msg + '</div>'
    obj.css('border-color', 'rgb(219, 46, 48)')
    obj.after(html)       
  }    
}
              
            
!
999px

Console