$(function () { $('#submit').click(function () { var b = $('#sitename').val(); var c = $('#siteurl').val(); var e = $('#code').val(); if (b == '' || c == '' || e == '') return layer.msg('请完成所有内容的填写!'); var f = new RegExp(/http(s)?:\/\/([\w-]+\.)+[\w-]+(\/[\w- .\/?%&=]*)?/); var g = new RegExp('^((https|http|ftp|rtsp|mms)?://)' + '?(([0-9a-z_!~*\'().&=+$%-]+: )?[0-9a-z_!~*\'().&=+$%-]+@)?' + '(([0-9]{1,3}.){3}[0-9]{1,3}' + '|' + '([0-9a-z_!~*\'()-]+.)*' + '([0-9a-z][0-9a-z-]{0,61})?[0-9a-z].' + '[a-z]{2,6})' + '(:[0-9]{1,4})?' + '((/?)|' + '(/[0-9a-z_!~*\'().;?:@&=+$,%#-]+)+/?)$'); isok = f.test(c); isok1 = g.test(c); if (!isok1) return layer.msg('网站地址填写错误,请重新填写'); if (!isok) return layer.msg('请填写带有 http(s):// 的网址'); $.ajax({ url: '/ajax.do?act=add', type: 'POST', dataType: 'json', data: {sitename: b, siteurl: c, code: e}, success: function (a) { if (a.error == 0) { setTimeout('window.location.reload()', 2000); $('#submit').attr('disabled', 'disabled'); $('#submit').addClass('disabled') } $('#captcha').click(); return layer.msg(a.msg) }, error: function (a) { layer.msg('数据提交失败,请检查您的网络') } }) }) });