passwd.tmpl 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. {{template "header.tmpl" .}}
  2. </head>
  3. <body>
  4. {{template "navbar.tmpl" .}}
  5. <div class="container-fluid">
  6. <form class="center-block" id="mainform" style="width:400px;">
  7. <div class="form-group">
  8. <label>ID</label>
  9. <input type="text" class="form-control" name="" value="{{.Sess.Account.Id}}" maxlength="20" readonly="readonly" />
  10. </div>
  11. <div class="form-group">
  12. <label>用户名</label>
  13. <input type="text" class="form-control" name="" value="{{.Sess.Account.Account}}" maxlength="20" readonly="readonly" />
  14. </div>
  15. <div class="form-group">
  16. <label>旧密码</label>
  17. <input type="password" class="form-control" name="oldpwd" value="" maxlength="20" />
  18. </div>
  19. <div class="form-group">
  20. <label>新密码(6位以上)</label>
  21. <input type="password" class="form-control" name="newpwd" value="" maxlength="20" />
  22. </div>
  23. <div class="form-group">
  24. <label>重复新密码</label>
  25. <input type="password" class="form-control" name="newpwd2" value="" maxlength="20" />
  26. </div>
  27. <button class="btn btn-primary">提交</button>
  28. </form>
  29. </div>
  30. <script type="text/javascript">
  31. var $SESS = {{.Sess}};
  32. $(function(){
  33. $('#mainform').submit(function(){
  34. if (this.oldpwd.value == '') {
  35. $.alert({'content': '旧密码不能为空!'});
  36. } else if (this.oldpwd.value.length < 6) {
  37. $.alert({'content': '旧密码格式不正确!'});
  38. } else if (this.newpwd.value == '') {
  39. $.alert({'content': '新密码不能为空!'});
  40. } else if (this.newpwd.value.length < 6) {
  41. $.alert({'content': '新密码格式不正确!'});
  42. } else if (this.newpwd2.value != this.newpwd.value) {
  43. $.alert({'content': '新密码两次输入不一致!'});
  44. } else {
  45. $.post('/profile/passwd', $(this).serialize(), function(resp){
  46. if (resp.errno) {
  47. $.alert({'content': resp.error});
  48. } else {
  49. $.alert({'content': '修改成功!'});
  50. }
  51. }, 'json');
  52. }
  53. return false;
  54. });
  55. });
  56. </script>
  57. </body>
  58. </html>