use-with-bootstrap.html 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1">
  6. <title>Used With Bootstrap</title>
  7. <link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap.min.css">
  8. <style>
  9. .n-bootstrap .msg-wrap {font-size: 14px; margin-top: 3px}
  10. </style>
  11. </head>
  12. <body>
  13. <div class="container" style="margin-top:30px">
  14. <div class="col-md-5 col-md-offset-2">
  15. <form id="form1" data-validator-option="{theme:'bootstrap', timely:2, stopOnError:true}">
  16. <div class="form-group">
  17. <label class="control-label">Username</label>
  18. <input type="text" class="form-control" name="username"
  19. data-rule="required;username;"
  20. data-rule-username="[/[\w\d]{4,30}/, 'Please enter 3-12 digits, letters, underscores']"
  21. data-tip="You can use letters, numbers and periods"
  22. >
  23. </div>
  24. <div class="form-group">
  25. <label class="control-label">Password</label>
  26. <input type="password" class="form-control" name="pwd"
  27. data-rule="Password: required; length(8~16)"
  28. data-tip="Please fill in at least eight characters"
  29. >
  30. </div>
  31. <div class="form-group">
  32. <label class="control-label">Verify Password</label>
  33. <input type="password" class="form-control" name="pwdAgain" data-rule="Verify Password: required; match(pwd)">
  34. </div>
  35. <div class="form-group">
  36. <label class="control-label">Gender</label>
  37. <select class="form-control" name="gender" data-rule="required">
  38. <option value="">select ...</option>
  39. <option value="1">Male</option>
  40. <option value="2">Female</option>
  41. <option value="3">Other</option>
  42. </select>
  43. </div>
  44. <div class="form-group">
  45. <label class="control-label">Email</label>
  46. <input type="text" class="form-control" name="email" data-rule="required;email">
  47. </div>
  48. <div class="form-group">
  49. <label class="control-label">Interest</label>
  50. <div class="">
  51. <label class="checkbox-inline"><input type="checkbox" name="interest" data-rule="checked">sports</label>
  52. <label class="checkbox-inline"><input type="checkbox" name="interest">movie</label>
  53. <label class="checkbox-inline"><input type="checkbox" name="interest">game</label>
  54. </div>
  55. </div>
  56. <div class="form-group">
  57. <label class="control-label">Note</label>
  58. <textarea class="form-control" data-rule="required;"></textarea>
  59. </div>
  60. <div class="form-group">
  61. <label class="checkbox-inline"><input type="checkbox" id="agree_arguments" data-rule="checked">I agree to the service agreement.</label>
  62. </div>
  63. <div class="form-group">
  64. <button type="submit" class="btn btn-primary">Submit</button>
  65. <button type="reset" class="btn btn-default">reset</button>
  66. </div>
  67. </form>
  68. </div>
  69. </div>
  70. <script src="https://cdn.jsdelivr.net/jquery/1.12.3/jquery.min.js"></script>
  71. <script src="../dist/jquery.validator.js?local=en"></script>
  72. <script>
  73. $(function(){
  74. // Custom theme
  75. $.validator.setTheme('bootstrap', {
  76. validClass: 'has-success',
  77. invalidClass: 'has-error',
  78. bindClassTo: '.form-group',
  79. formClass: 'n-default n-bootstrap',
  80. msgClass: 'n-right'
  81. });
  82. });
  83. </script>
  84. </body>
  85. </html>