Pen Settings

HTML

CSS

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

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

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.

HTML

              
                <!-- 圖文:https://mnya.tw/cc/word/1773.html -->
<form class="cmxform" id="TestForm" method="get" action="">
  <fieldset>
    <legend>請提供以下資料:(jQuery Validate 測試用)</legend>
    <p>
      <label for="name">姓名 (必填)</label><br>
      <input id="name" name="name" type="text" required>
    </p>
    <p>
      <label for="username">帳號 (必填)</label><br>
      <input id="username" name="username" type="text" required>
    </p>
    <p>
      <label for="password">密碼 (必填)</label><br>
      <input id="password" name="password" type="password">
    </p>
    <p>
      <label for="confirm_password">確認密碼 (必填)</label><br>
      <input id="confirm_password" name="confirm_password" type="password">
    </p>
    <p>
      <label for="cemail">E-mail (必填)</label><br>
      <input id="cemail" type="email" name="email" required>
    </p>
    <p>
      <label for="curl">URL (可選)</label><br>
      <input id="curl" type="url" name="url">
    </p>
    <p>
      <label for="introduction">個人簡介 (可選)</label><br>
      <textarea id="introduction" name="introduction"></textarea>
    </p>
    <p>
      <input class="submit" type="submit" value="提交">
    </p>
  </fieldset>
</form>
              
            
!

CSS

              
                #TestForm {
  width: 400px;
  font-size: 15px;
}

#TestForm p {
  margin: 5px 0;
}

#TestForm input {
  margin: 5px 0;
}

#TestForm label.error {
  font-size: 14px;
  margin-left: 10px;
  color: red;
}

              
            
!

JS

              
                $.validator.setDefaults({
  submitHandler: function () {
    alert("成功提交!");
  }
});

$().ready(function () {
  // 在輸入後及提交時驗證表單欄位是否格式正確
  $("#TestForm").validate({
    rules: {
      name: {
        required: true,
        minlength: 2
      },
      username: {
        required: true,
        range: [6, 12]
      },
      password: {
        required: true,
        minlength: 6
      },
      confirm_password: {
        required: true,
        minlength: 6,
        equalTo: "#password"
      },
      email: {
        required: true,
        email: true
      }
    },
    messages: {
      name: {
        required: "姓名為必填",
        minlength: "姓名至少要有兩個字"
      },
      username: {
        required: "帳號為必填",
        range: $.validator.format("您的帳號必須 {0} 到 {1} 個字元")
      },
      password: {
        required: "密碼為必填",
        minlength: $.validator.format("您的密碼必須至少 {0} 個字元")
      },
      confirm_password: {
        required: "確認密碼為必填",
        minlength: $.validator.format("您的密碼必須至少 {0} 個字元"),
        equalTo: "請輸入與以上一樣的密碼"
      },
      email: "請輸入正確的 E-mail 地址"
    }
  });
});

              
            
!
999px

Console