backend.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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. $("#article-form #reset-btn").click(function(){
  30. var articleForm = $("#article-form");
  31. articleForm.data('bootstrapValidator').resetForm(true);
  32. articleForm[0].reset();
  33. });
  34. /* user add */
  35. $("#user-form").bootstrapValidator({
  36. validatorDefaultParam,
  37. fields : {
  38. name : {
  39. validators : {
  40. notEmpty : {
  41. message : "请输入姓名"
  42. },
  43. stringLength : {
  44. min : 2,
  45. max : 30,
  46. message : '姓名长度必须在2-30'
  47. }
  48. }
  49. },
  50. email : {
  51. validators : {
  52. notEmpty : {
  53. message : "请输入登录邮箱"
  54. },
  55. emailAddress : {
  56. message : "请输入正确的登录邮箱"
  57. }
  58. }
  59. },
  60. password : {
  61. validators : {
  62. notEmpty : {
  63. message : "请输入正确的登录密码"
  64. },
  65. stringLength : {
  66. min : 8,
  67. max : 30,
  68. message : '请输入8-30位的密码'
  69. }
  70. }
  71. }
  72. }
  73. });
  74. $("#user-form #reset-btn").click(function(){
  75. $("#user-form").data('bootstrapValidator').resetForm(true);
  76. $("#user-form")[0].reset();
  77. });
  78. /* user edit */
  79. $("#edit-user-form").bootstrapValidator({
  80. validatorDefaultParam,
  81. fields : {
  82. name : {
  83. validators : {
  84. notEmpty : {
  85. message : "请输入姓名"
  86. },
  87. stringLength : {
  88. min : 2,
  89. max : 30,
  90. message : '姓名长度必须在2-30'
  91. }
  92. }
  93. },
  94. email : {
  95. validators : {
  96. notEmpty : {
  97. message : "请输入登录邮箱"
  98. },
  99. emailAddress : {
  100. message : "请输入正确的登录邮箱"
  101. }
  102. }
  103. },
  104. password : {
  105. validators : {
  106. stringLength : {
  107. min : 8,
  108. max : 30,
  109. message : '请输入8-30位的密码'
  110. }
  111. }
  112. }
  113. }
  114. });
  115. $("#edit-user-form #reset-btn").click(function(){
  116. $("#user-form").data('bootstrapValidator').resetForm(true);
  117. $("#user-form")[0].reset();
  118. });
  119. $("#tag-form").bootstrapValidator({
  120. validatorDefaultParam,
  121. fields : {
  122. name: {
  123. validators: {
  124. notEmpty: {
  125. message: "请输入文章标签名"
  126. }
  127. }
  128. }
  129. }
  130. });
  131. $("#tag-form #reset-btn").click(function(){
  132. $("#tag-form").data('bootstrapValidator').resetForm(true);
  133. $("#tag-form")[0].reset();
  134. });
  135. $("#link-form").bootstrapValidator({
  136. validatorDefaultParam,
  137. fields : {
  138. name: {
  139. validators: {
  140. notEmpty: {
  141. message: "请输入链接名"
  142. }
  143. }
  144. },
  145. url : {
  146. validators: {
  147. notEmpty: {
  148. message: "URL不能为空"
  149. },
  150. uri: {
  151. message: '请输入合法的URL地址'
  152. }
  153. }
  154. }
  155. }
  156. });
  157. $("#link-form #reset-btn").click(function(){
  158. $("#link-form").data('bootstrapValidator').resetForm(true);
  159. $("#link-form")[0].reset();
  160. });
  161. $("#navigation-form").bootstrapValidator({
  162. validatorDefaultParam,
  163. fields : {
  164. name: {
  165. validators: {
  166. notEmpty: {
  167. message: "请输入导航名"
  168. }
  169. }
  170. },
  171. url : {
  172. validators: {
  173. notEmpty: {
  174. message: "URL不能为空"
  175. },
  176. uri: {
  177. message: '请输入合法的URL地址'
  178. }
  179. }
  180. }
  181. }
  182. });
  183. $("#navigation-form #reset-btn").click(function(){
  184. $("#navigation-form").data('bootstrapValidator').resetForm(true);
  185. $("#navigation-form")[0].reset();
  186. });
  187. });