.... <script type="text/javascript" src="GTAjax_.js"></script> .... |
v3.10+ 面向对象的调用实例: |
.... function subMyForm(sFrm) |
.... <span id="formArea">(请将form放到一个对象中去,place form in a named object) |
.... setGTAjax('subbtnval','Submit'); // 表单递交按钮显示的字符,默认是Submit setGTAjax('maxuploadfiletime',3*60*1000); // 上传文件等待回应的最大时间,默认是3分钟 setGTAjax('targetarea','areaname'); // 递交请求获取数据后写在当前页面的何处,默认是递交元素所在的区域 setGTAjax('returnname','Return'); // 表单递交后,返回链接的显示字符,默认是Return setGTAjax('returndataonly',false); // 是否仅仅取得返回数据(而不向目标区域写入),默认是false setGTAjax('iscache',true); // 是否缓存从服务器取得的内容,默认是true setGTAjax('forceframe',false); // 是否强制使用iframe技术,即便没有fileupload行为也不使用xmlhttp,在一些xmlhttp受限的地方可使用iframe代替 setGTAjax ('processbar',true); // 是否显示处理中提示条, 默认是显示 (1.89+, idea from ayg at founder dot com) setGTAjax ('backlink',true); // 是否在返回内容中追加返回链接,默认为是(1.89+ ) setGTAjax('forceframetag','fftag'); //告知服务器端,此次请求是普通请求,非xmlhttp,服务器端可据此fftag=1来判断(1.91+) setGTAjax('chkform','userMail:email+:user mail should be an valid email address'); // 设定表单递交验证项(详细见下表) v3.0+的属性设置, 在上述的名称前加一个实例对象: gtajaxinstance.setGTAjax(name, value) ; 或者 gtajaxinstance.set(name, value); 取值的地方也增加了: gtajaxinstance.get( object ) ; v4.0新增属性设置: gtajaxinstance.set('nobacktag',''); //--- 设定如果服务器端返回的内容中含有此字串则不在内容后面附加"返回"的链接 gtajaxinstance.set('nocopy',false); //--- 设定是否禁止加载页面的内容被复制 v5.2新增属性和不兼容设置: 1.表单验证的写法: <input type="text" name="email_address" id="email_address" accept="email+::Please input correct Email" /> 与之前相比: 1.1 表单验证的设置,可以不再通过 gtajaxinstance.set('chkform','strFormFieldName:formValidateType: errorMessage') 的方式设置 1.2 设置项,不再使用 : ,而是使用2个 : ,也即 :: 来分割设置项内容 .... |
'userMail: email+: user mail should be an valid email address' 'strFormFieldName:formValidateType: errorMessage' Configuration seperation tag ':' --> '::' since v5.2, 201107GTAjax Form Validation Descriptors // GTAjax 表单验证关键字描述
formValidateType | Explainations[partly from http://www.javascript-coder.com ] |
required req |
The field should not be empty // 不能为空 |
maxlen=??? maxlength=??? |
checks the length entered data to the maximum. For
example, if the maximum size permitted is 25, give the validation descriptor as "maxlen=25"
// 长度检测,至多允可长度, 如欲限定在25字符内,则使用表达式, "maxlen=25", 在GTAjax中的完整表达为
setGTAjax('chkform','strField:maxlen=25:this field max length is 25.'); |
minlen=??? minlength=??? |
checks the length of the entered string to the required minimum. example "minlen=5" //最小限定为 |
alphanumeric alnum |
Check the data if it contains any other characters other than alphabetic or numeric characters //仅为字母和数字(不含符号等) |
num numeric |
Check numeric data // 仅为数字 |
alpha alphabetic |
Check alphabetic data. // 仅为字母 |
The field is an email field and verify the validity of the data. // 限为合法email地址 | |
lt=??? lessthan=??? |
Verify the data to be less than the value passed.
Valid only for numeric fields. example: if the value should be less than 1000 give validation description as "lt=1000" // 其值不大于 |
gt=??? greaterthan=??? |
Verify the data to be greater than the value passed.
Valid only for numeric fields. example: if the value should be greater than 10 give validation description as "gt=10" // 其值不小于 |
regexp=??? |
Check with a regular expression the value should match the regular expression. example: "regexp=^[A-Za-z]{1,20}$" allow up to 20 alphabetic characters. // 其值符合给定的正则表达式 |
dontselect=?? Deprecated |
This validation descriptor is valid only for select input items (lists) Normally, the select list boxes will have one item saying 'Select One' or some thing like that. The user should select an option other than this option. If the index of this option is 0, the validation description should be "dontselect=0" // 这个是 http://www.javascript-coder.com 的标配, 其本身局限大,功能小,舍弃 |
notvalue=??? newlyadded |
Verify the data to be any data other than the specified value // 是上面一个的的升级和扩容,是一个反向概括,如不能让其值为空"notvalue=" , 不能选择第一个选项"notvalue=1",用户名一项的值不能等于初始值"notvalue=用户名"... |
(anyofabove)+ newlyadded |
the "+" means req, or required, not empty when added up to any type of validating above, e.g. "email+" which means the expected value is an email address, and the field also is required, not empty. // 在写表单验证时参考了很多目前流行的,这个就是精简的结果,比如其中一项,即要符合email地址规范,又不能为空,则 "email+" , 其中一项只能是数字,且不能留空,则 "num+",... |