javascript校验实例一?//公共类型validTypeArray new Array()/** * 给窗体绑定resize事件 */function
javascript校验实例一
?
//公共类型;validTypeArray = new Array();/** * 给窗体绑定resize事件; */function bindResizeEvent(){//移除窗体改变大小时触发的事件;jQuery(window).unbind("resize");//窗体改变大小时触发resize事件;jQuery(window).resize(function(){submitCommonJS();});}/** * 移除图标方法; * @param txtObj */function removeImage(txtObj){//移除图标;txtObj.parent().children("#successDivID").remove();txtObj.parent().children("#errorDivID").remove();txtObj.parent().children("#tipMsgDivID").remove();txtObj.parent().children("#errorMsgDivId").remove();txtObj.parent().children("#pointerDivID").remove();}//设置鼠标移动到图标上面移除事件;jQuery(document).ready(function(){//给第一个文本框获取焦点;jQuery("input[type='text']").first().focus();jQuery("input[type='text']").each(function(i){//移出绑定事件;jQuery(this).unbind("mouseover");//绑定事件;jQuery(this).bind("mouseover",function(){jQuery(this).parent().children("#tipMsgDivID").hide();});});});//检验对象;CheckOut = function(){//字段数组;var fieldArray = new Array();//添加addField对象;this.addField = function(options){// 以ID的方式获取文本框this.id = options.id == undefined ? null:options.id;// 以名称的方式获取文本框this.name = options.name == undefined ? null:options.name;// 以类样式的方式获取文本框this.className = options.className == undefined ? null:options.className;// 文本框是否必须this.isRequired = options.isRequired == undefined ? false:options.isRequired;// 校验类型this.validType = options.validType == undefined ? null:options.validType;// 文本框为空时的提示信息this.emptyMsg = options.emptyMsg == undefined ? $("#emptyMsg").val():options.emptyMsg;// 文本框校验失败时的提示信息this.invalidMsg = options.invalidMsg == undefined ? null:options.invalidMsg;// 文本框的默认值this.defaultValue = options.defaultValue == undefined ? null:options.defaultValue;//往数组中添加addField对象;fieldArray.push(options);};//返回数组;this.getFieldArray=function(){return fieldArray;};};/** * 替换国际化; * @param i18nMsgInfo * @param param1 * @param param2 * @returns */CheckOut.replace = function (i18nMsgInfo,param1,param2){if(i18nMsgInfo!=null && i18nMsgInfo!=""){i18nMsgInfo = i18nMsgInfo.replace("{0}",param1);i18nMsgInfo = i18nMsgInfo.replace("{1}",param2);}return i18nMsgInfo;};? 