backend.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. $(function() {
  2. var validatorDefaultParam = {
  3. live: 'disables',
  4. message: "This Values is not valid",
  5. feedbackIcons: {
  6. valid: 'glyphicon ',
  7. invalid: 'glyphicon ',
  8. validating: 'glyphicon glyphicon-refresh'
  9. }
  10. };
  11. /* 文章分类操作验证 */
  12. $("#category-form").bootstrapValidator({
  13. validatorDefaultParam,
  14. fields: {
  15. name: {
  16. validators: {
  17. notEmpty: {
  18. message: "分类名称不能为空"
  19. }
  20. }
  21. }
  22. }
  23. });
  24. $("#category-form #reset-btn").click(function(){
  25. var categoryForm = $("#category-form");
  26. categoryForm.data('bootstrapValidator').resetForm(true);
  27. categoryForm[0].reset();
  28. });
  29. /* 文章操作验证 */
  30. $("#article-form").bootstrapValidator({
  31. validatorDefaultParam,
  32. fields : {
  33. title : {
  34. validators : {
  35. notEmpty : {
  36. message : "文章标题不能为空"
  37. }
  38. }
  39. },
  40. cate_id : {
  41. validators : {
  42. notEmpty : {
  43. message : "请选择文章分类"
  44. }
  45. }
  46. }
  47. }
  48. });
  49. $("#article-form #reset-btn").click(function(){
  50. var articleForm = $("#article-form");
  51. articleForm.data('bootstrapValidator').resetForm(true);
  52. articleForm[0].reset();
  53. });
  54. /* user add */
  55. $("#user-form").bootstrapValidator({
  56. validatorDefaultParam,
  57. fields : {
  58. name : {
  59. validators : {
  60. notEmpty : {
  61. message : "请输入姓名"
  62. },
  63. stringLength : {
  64. min : 2,
  65. max : 30,
  66. message : '姓名长度必须在2-30'
  67. }
  68. }
  69. },
  70. email : {
  71. validators : {
  72. notEmpty : {
  73. message : "请输入登录邮箱"
  74. },
  75. emailAddress : {
  76. message : "请输入正确的登录邮箱"
  77. }
  78. }
  79. },
  80. password : {
  81. validators : {
  82. notEmpty : {
  83. message : "请输入正确的登录密码"
  84. },
  85. stringLength : {
  86. min : 8,
  87. max : 30,
  88. message : '请输入8-30位的密码'
  89. }
  90. }
  91. }
  92. }
  93. });
  94. $("#user-form #reset-btn").click(function(){
  95. $("#user-form").data('bootstrapValidator').resetForm(true);
  96. $("#user-form")[0].reset();
  97. });
  98. /* user edit */
  99. $("#edit-user-form").bootstrapValidator({
  100. validatorDefaultParam,
  101. fields : {
  102. name : {
  103. validators : {
  104. notEmpty : {
  105. message : "请输入姓名"
  106. },
  107. stringLength : {
  108. min : 2,
  109. max : 30,
  110. message : '姓名长度必须在2-30'
  111. }
  112. }
  113. },
  114. email : {
  115. validators : {
  116. notEmpty : {
  117. message : "请输入登录邮箱"
  118. },
  119. emailAddress : {
  120. message : "请输入正确的登录邮箱"
  121. }
  122. }
  123. },
  124. password : {
  125. validators : {
  126. stringLength : {
  127. min : 8,
  128. max : 30,
  129. message : '请输入8-30位的密码'
  130. }
  131. }
  132. }
  133. }
  134. });
  135. $("#edit-user-form #reset-btn").click(function(){
  136. $("#user-form").data('bootstrapValidator').resetForm(true);
  137. $("#user-form")[0].reset();
  138. });
  139. $("#tag-form").bootstrapValidator({
  140. validatorDefaultParam,
  141. fields : {
  142. name: {
  143. validators: {
  144. notEmpty: {
  145. message: "请输入文章标签名"
  146. }
  147. }
  148. }
  149. }
  150. });
  151. $("#tag-form #reset-btn").click(function(){
  152. $("#tag-form").data('bootstrapValidator').resetForm(true);
  153. $("#tag-form")[0].reset();
  154. });
  155. $("#link-form").bootstrapValidator({
  156. validatorDefaultParam,
  157. fields : {
  158. name: {
  159. validators: {
  160. notEmpty: {
  161. message: "请输入链接名"
  162. }
  163. }
  164. },
  165. url : {
  166. validators: {
  167. notEmpty: {
  168. message: "URL不能为空"
  169. },
  170. uri: {
  171. message: '请输入合法的URL地址'
  172. }
  173. }
  174. }
  175. }
  176. });
  177. $("#link-form #reset-btn").click(function(){
  178. $("#link-form").data('bootstrapValidator').resetForm(true);
  179. $("#link-form")[0].reset();
  180. });
  181. });