cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

Code Indentation

     

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.

            
              <form action="#" id="form1">
  <h1>普通に送信するフォーム</h1>
  <div>
    <label for="name">キーワードを入力してください。</label>
    <input type="text" name="name1" id="name1" placeholder="hoge" />
  </div>
  <div>
    <input type="submit" value="Submit" />
  </div>
</form>

<form action="#" id="form2">
  <h1>未入力で送信したらplaceholderの値を送信</h1>
  <div>
    <label for="name">キーワードを入力してください。</label>
    <input type="text" name="name2" id="name2" placeholder="テイラー・スウィフト" />
  </div>
  <div>
    <input type="submit" value="Submit" />
  </div>
</form>
            
          
!
            
              form {
  margin: 3em;
}
h1 {
  font-size: 1em;
  margin: .5em;
}
div {
  margin: .5em;
}
label {
  display: block;
}

            
          
!
            
              $(function(){
  $('#form1').on({
    'submit': function(){
      var o = $(this).find('#name1');
      if(o.val() === '') {
        alert('何も入力されてません');
      } else {
        alert("ユーザーが入力した\n[" + o.val() + "]\nを送信");
      }
      return false;
    }
  });
  $('#form2').on({
    'submit': function(){
      var o = $(this).find('#name2');
      if(o.val() === '') {
        o.val(o.attr('placeholder'));
        alert("何も入力されていない場合は\nplaceholder値[" + o.val() + "]\nを送信");
      } else {
        alert("ユーザーが入力した\n[" + o.val() + "]\nを送信");
      }
      return false;
    }
  });
	$('input[type=text]').on('click', function(){
		$(this).select();
	});
});
            
          
!
999px
Loading ..................

Console