参考资料:
http://code.ciaoca.com/jquery/validation_engine/
http://www.cnblogs.com/aijun/archive/2011/03/21/1989991.html
http://csjava.blog.163.com/blog/static/1904700332012112065228299/
jsp:
- <textareaname="content"id="content"cols="120"rows="4"style="overflow:auto;"
- class="validate[required,ajax[sensitiveWord]]"></textarea>
<textarea name="content" id="content" cols="120" rows="4" style="overflow: auto;" class="validate[required,ajax[sensitiveWord]]"></textarea>
jquery.validationEngine-zh_CN.js:(Validation Engine 2.2.4 ,jQuery plugin,2.2.4版本的 )
- "sensitiveWord":{
- "url":"test!validateInfo.fhtm",
- "extraDataDynamic":['#content'],
- "alertTextLoad":"验证中,请等待..."
- },
"sensitiveWord":{ "url": "test!validateInfo.fhtm","extraDataDynamic": ['#content'],"alertTextLoad": "验证中,请等待..." },
jquery.validationEngine.js: 需要修改以下的内容:
- _ajax:function(field,rules,i,options){
- varerrorSelector=rules[i+1];
- varrule=options.allrules[errorSelector];
- varextraData=rule.extraData;
- varextraDataDynamic=rule.extraDataDynamic;
- if(!extraData)
- extraData="";
- if(extraDataDynamic){
- vartmpData=[];
- vardomIds=String(extraDataDynamic).split(",");
- for(vari=0;i<domIds.length;i++){
- varid=domIds[i];
- if($(id).length){
- varinputValue=field.closest("form").find(id).val();
- varkeyValue=id.replace('#','')+'='+
- encodeURIComponent(encodeURIComponent(inputValue));
- //修改这里,原来的方法有点老,代码越界了,不需要换行
- tmpData.push(keyValue);
- }
- }
- extraDataDynamic=tmpData.join("&");
- }else{
- extraDataDynamic="";
- }
_ajax: function(field,options) { var errorSelector = rules[i + 1]; var rule = options.allrules[errorSelector]; var extraData = rule.extraData; var extraDataDynamic = rule.extraDataDynamic; if (!extraData) extraData = ""; if (extraDataDynamic) { var tmpData = []; var domIds = String(extraDataDynamic).split(","); for (var i = 0; i < domIds.length; i++) { var id = domIds[i]; if ($(id).length) { var inputValue = field.closest("form").find(id).val(); var keyValue = id.replace('#','') + '=' + encodeURIComponent(encodeURIComponent(inputValue)); //修改这里,原来的方法有点老,代码越界了,不需要换行 tmpData.push(keyValue); } } extraDataDynamic = tmpData.join("&"); } else { extraDataDynamic = ""; }
java:
原文链接:https://www.f2er.com/ajax/166768.html