(function($) { $.from = { /** * 弹窗title */ title : "填写资料", /** * 域名验证 * * @param {} * domainId id */ checkDomain : function(domainId) { var domain = $(domainId).val(); var reg = /^([a-zA-Z0-9-])+$/; if ((domain == "") || (domain.length <= 0)) { jAlert('请填写您要申请的域名', this.title); return false; } if (!reg.test(domain)) { jAlert('域名格式不正确', this.title); return false; } if (domain.length > 36) { jAlert('域名长度过长', this.title); return false; } return 1; }, /** * 验证企业名称 必须包含中文 * * @param {} * companyName */ checkCompanyName : function(companyName) { var companyName = $(companyName).val(); if ((companyName == '') || (companyName.length <= 0)) { jAlert('请填写企业名称', this.title); return false; } if((companyName.indexOf("_") != -1) || (!/^(\w*[\u4e00-\u9fa5]+\w*)*$/.test(companyName))){ jAlert('企业名称必须包含中文,可以包含字母数组但不能包含特殊字符', this.title); return false; } return 1; }, checkProvince : function(province){ var province = $(province); if(province.get(0).selectedIndex <=0){ jAlert('请选择省份',this.title); return false; } return 1; }, /** * 检测是否同意协议 * * @param {} * agree */ checkIsAgree : function(agree) { var agree = $(agree); if (!agree.is(':checked')) { jAlert('您还没有同意"诚信企业协议"', this.title); return false; } return 1; }, /** * 验证邮箱 */ checkMail : function(email) { var reg = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/; var email = $(email).val(); if ((email == '') || (email.length <= 0)) { jAlert("请输入您的邮箱!", this.title); return false; } if (!reg.test(email)) { jAlert("您输入的邮箱格式不正确,请重新输入!", this.title); return false; } return 1; }, /** * 表单验证 */ binding : function() { return this.checkDomain('#domainName') && this.checkCompanyName('#companyName') && this.checkProvince("#province") && this.checkIsAgree('#agree'); } } })(jQuery); /** * 绑定事件 */ $(document).ready(function() { $("#userInfoForm").bind("submit", function() { return $.from.binding(); }); });
详细解决方案
关于中文的验证有关问题
热度:102 发布时间:2012-11-01 11:11:33.0
相关解决方案