forms.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. $(function () {
  2. $(".input").focus(function () {
  3. $(this).attr("class", "inputOn");
  4. }).blur(function () {
  5. $(this).attr("class", "input");
  6. });
  7. $("#dbhost").focus();
  8. })
  9. function CheckForm() {
  10. var format = /^[a-zA-Z0-9_@!.-]+$/;
  11. if ($("#dbhost").val() == "") {
  12. alert("请输入数据库服务器!");
  13. $("#dbhost").focus();
  14. return false;
  15. }
  16. if ($("#dbname").val() == "") {
  17. alert("请输入数据库名!");
  18. $("#dbname").focus();
  19. return false;
  20. }
  21. if (!format.exec($("#dbname").val())) {
  22. alert("数据库名非法!请使用[a-zA-Z0-9_@!.-]内的字符!!");
  23. $("#dbname").focus();
  24. return false;
  25. }
  26. if ($("#dbuser").val() == "") {
  27. alert("请输入数据库用户!");
  28. $("#dbuser").focus();
  29. return false;
  30. }
  31. // if ($("#username").val() == "") {
  32. // alert("请输入管理员账号!");
  33. // $("#username").focus();
  34. // return false;
  35. // }
  36. //
  37. // if ($("#username").val().length < 5 ||
  38. // $("#username").val().length > 20) {
  39. // alert("用户名长度不得小于5位或大于20位!");
  40. // $("#username").focus();
  41. // return false;
  42. // }
  43. //
  44. // if ($("#password").val() == "") {
  45. // alert("请输入管理员密码!");
  46. // $("#password").focus();
  47. // return false;
  48. // }
  49. //
  50. // if ($("#password").val().length < 5 ||
  51. // $("#password").val().length > 16) {
  52. // alert("密码由5-16个字符组成,区分大小写!");
  53. // $("#password").focus();
  54. // return false;
  55. // }
  56. //
  57. // if ($("#repassword").val() == "") {
  58. // alert("请输入重复密码!");
  59. // $("#repassword").focus();
  60. // return false;
  61. // }
  62. //
  63. // if ($("#password").val() != $("#repassword").val()) {
  64. // alert("两次密码不同!");
  65. // $("#repassword").focus();
  66. // return false;
  67. // }
  68. if ($("#cpwd").val() == "false") {
  69. $.ajax({
  70. url: 'index.php',
  71. data: {
  72. s: 63832,
  73. dbhost: $("#dbhost").val(),
  74. dbuser: $("#dbuser").val(),
  75. dbpwd: $("#dbpwd").val(),
  76. },
  77. type: 'get',
  78. dataType: 'html',
  79. success: function (data) {
  80. if (data == 'true') {
  81. $('#cpwdTxt').html('<span class="correct">可用</span>');
  82. $('#cpwd').val("true");
  83. //验证没有问题,提交表单
  84. document.form.submit();
  85. return;
  86. } else {
  87. $('#cpwdTxt').html('<span class="error">不可用</span>');
  88. $("#dbpwd").focus();
  89. $('#cpwd').val("false");
  90. return false;
  91. }
  92. }
  93. });
  94. } else {
  95. //验证没有问题,提交表单
  96. document.form.submit();
  97. return;
  98. }
  99. }
  100. /**
  101. * 验证数据库账号密码是否正确
  102. * @constructor
  103. */
  104. function CheckPwd() {
  105. $.ajax({
  106. url: 'index.php',
  107. data: {
  108. s: 63832,
  109. dbhost: $("#dbhost").val(),
  110. dbport: $("#dbport").val(),
  111. dbuser: $("#dbuser").val(),
  112. dbpwd: $("#dbpwd").val(),
  113. },
  114. type: 'get',
  115. dataType: 'html',
  116. success: function (data) {
  117. if (data === 'true') {
  118. $('#cpwdTxt').html('<span class="correct">可用</span>');
  119. $('#cpwd').val("true");
  120. } else {
  121. $('#cpwdTxt').html('<span class="error">不可用</span>');
  122. $('#cpwd').val("false");
  123. }
  124. }
  125. });
  126. }