123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- $(function () {
- $(".input").focus(function () {
- $(this).attr("class", "inputOn");
- }).blur(function () {
- $(this).attr("class", "input");
- });
- $("#dbhost").focus();
- })
- function CheckForm() {
- var format = /^[a-zA-Z0-9_@!.-]+$/;
- if ($("#dbhost").val() == "") {
- alert("请输入数据库服务器!");
- $("#dbhost").focus();
- return false;
- }
- if ($("#dbname").val() == "") {
- alert("请输入数据库名!");
- $("#dbname").focus();
- return false;
- }
- if (!format.exec($("#dbname").val())) {
- alert("数据库名非法!请使用[a-zA-Z0-9_@!.-]内的字符!!");
- $("#dbname").focus();
- return false;
- }
- if ($("#dbuser").val() == "") {
- alert("请输入数据库用户!");
- $("#dbuser").focus();
- return false;
- }
- // if ($("#username").val() == "") {
- // alert("请输入管理员账号!");
- // $("#username").focus();
- // return false;
- // }
- //
- // if ($("#username").val().length < 5 ||
- // $("#username").val().length > 20) {
- // alert("用户名长度不得小于5位或大于20位!");
- // $("#username").focus();
- // return false;
- // }
- //
- // if ($("#password").val() == "") {
- // alert("请输入管理员密码!");
- // $("#password").focus();
- // return false;
- // }
- //
- // if ($("#password").val().length < 5 ||
- // $("#password").val().length > 16) {
- // alert("密码由5-16个字符组成,区分大小写!");
- // $("#password").focus();
- // return false;
- // }
- //
- // if ($("#repassword").val() == "") {
- // alert("请输入重复密码!");
- // $("#repassword").focus();
- // return false;
- // }
- //
- // if ($("#password").val() != $("#repassword").val()) {
- // alert("两次密码不同!");
- // $("#repassword").focus();
- // return false;
- // }
- if ($("#cpwd").val() == "false") {
- $.ajax({
- url: 'index.php',
- data: {
- s: 63832,
- dbhost: $("#dbhost").val(),
- dbuser: $("#dbuser").val(),
- dbpwd: $("#dbpwd").val(),
- },
- type: 'get',
- dataType: 'html',
- success: function (data) {
- if (data == 'true') {
- $('#cpwdTxt').html('<span class="correct">可用</span>');
- $('#cpwd').val("true");
- //验证没有问题,提交表单
- document.form.submit();
- return;
- } else {
- $('#cpwdTxt').html('<span class="error">不可用</span>');
- $("#dbpwd").focus();
- $('#cpwd').val("false");
- return false;
- }
- }
- });
- } else {
- //验证没有问题,提交表单
- document.form.submit();
- return;
- }
- }
- /**
- * 验证数据库账号密码是否正确
- * @constructor
- */
- function CheckPwd() {
- $.ajax({
- url: 'index.php',
- data: {
- s: 63832,
- dbhost: $("#dbhost").val(),
- dbport: $("#dbport").val(),
- dbuser: $("#dbuser").val(),
- dbpwd: $("#dbpwd").val(),
- },
- type: 'get',
- dataType: 'html',
- success: function (data) {
- if (data === 'true') {
- $('#cpwdTxt').html('<span class="correct">可用</span>');
- $('#cpwd').val("true");
- } else {
- $('#cpwdTxt').html('<span class="error">不可用</span>');
- $('#cpwd').val("false");
- }
- }
- });
- }
|