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

              
                <div class="container">
  <h1>validate.js 台灣手機號碼認證範例</h1>
  <form id="myform">

    <div class="form-group">
      <label for="exampleInputEmail1">手機號碼</label>
      <input type="text" class="form-control" id="phone" placeholder="phone" name="phone">
    </div>
    <div>
      <input type="radio" id="ios" name="os" value="ios" checked />
      <label for="ios" class="text">
        <span>iOS</span>
      </label>&nbsp;&nbsp;
      <input type="radio" id="android" name="os" value="android" />
      <label for="android" class="text">
        <span>Android</span>
      </label>
    </div>
    <button type="submit" class="btn btn-primary">送出</button>
  </form>
</div>
</body>
              
            
!

CSS

              
                @media(min-width: 960px) { 
  .container {
    width: 450px;
    margin: 0 auto;
  }
}
.container h1 {
  margin: 20px;
  text-align: center;
}
.container form {
  padding: 20px;
  background: #EBF0F4;
  border-radius: 10px;
}
.error{
  color:#dc3545;
}
label.error{
  padding-top:5px;
}
              
            
!

JS

              
                jQuery.validator.methods.matches = function (value, element, params) {
    var re = new RegExp(params);
    return this.optional(element) || re.test(value);
  };
var re = new RegExp("^09\\d{8}$");
$( "#myform" ).validate({
  rules: {
    phone: {
      required: true,
      matches: re, // <-- no such method called "matches"!
    },
    os: {
      required: true,
    }
  },
  messages: {
    phone: {
      required: "請填寫您的手機號碼",
      matches: "您的手機號碼格式錯誤,需為10位的正確數字手機格式",
    },
     os: {
      required: "請填寫您的手機系統",
    },
  },
  submitHandler: function (form) {
    alert('成功送出!');
  }
});
              
            
!
999px

Console