forms.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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. var dbhost = $("#dbhost").val();
  70. var dbuser = $("#dbuser").val();
  71. var dbpwd = $("#dbpwd").val();
  72. $.ajax({
  73. url: 'index.php?s=63832' + '&dbhost=' + dbhost + '&dbuser=' + dbuser + '&dbpwd=' + dbpwd,
  74. type: 'get',
  75. dataType: 'html',
  76. success: function (data) {
  77. if (data == 'true') {
  78. $('#cpwdTxt').html('<span class="correct">可用</span>');
  79. $('#cpwd').val("true");
  80. //验证没有问题,提交表单
  81. document.form.submit();
  82. return;
  83. } else {
  84. $('#cpwdTxt').html('<span class="error">不可用</span>');
  85. $("#dbpwd").focus();
  86. $('#cpwd').val("false");
  87. return false;
  88. }
  89. }
  90. });
  91. } else {
  92. //验证没有问题,提交表单
  93. document.form.submit();
  94. return;
  95. }
  96. }
  97. function CheckPwd() {
  98. var dbhost = $("#dbhost").val();
  99. var dbuser = $("#dbuser").val();
  100. var dbpwd = $("#dbpwd").val();
  101. $.ajax({
  102. url: 'index.php?s=63832' + '&dbhost=' + dbhost + '&dbuser=' + dbuser + '&dbpwd=' + dbpwd,
  103. type: 'get',
  104. dataType: 'html',
  105. success: function (data) {
  106. if (data == 'true') {
  107. $('#cpwdTxt').html('<span class="correct">可用</span>');
  108. $('#cpwd').val("true");
  109. } else {
  110. $('#cpwdTxt').html('<span class="error">不可用</span>');
  111. $('#cpwd').val("false");
  112. }
  113. }
  114. });
  115. }