[i][b]本文为firedragonpzy原创,转载务必在明显处注明:
转载自【Softeware MyZone】原文链接: http://www.firedragonpzy.com.cn/index.php/archives/756[/b][/i]
转载自【Softeware MyZone】原文链接: http://www.firedragonpzy.com.cn/index.php/archives/756[/b][/i]
php -- inline和submit的ajax验证(包括三个地方需要配置)
1:文件中js配置(除了引入该有的js、css外还需此配置)
$(document).ready(function(){
// Called once the server replies to the ajax form validation request
function ajaxValidationCallback(status, form, json, options){
if(json[0][1]){
var action = "/sysrole/create";
form.attr("action",action);
form.validationEngine('detach');
form.submit();
}
}
$("#form_validate").validationEngine({
ajaxFormValidation: true,//开启表单提交验证
onAjaxFormComplete: ajaxValidationCallback//启用回调
});
});
2:表单:
<form id="form_validate" name="form_validate" action="/ajax/rolesubmit" method="post">
<input id="roleName" name="roleName" type="text" value="{$roleName}" class="validate[required],maxSize[30],ajax[ajaxRole] input">
</form>
3:验证:
"ajaxRole": {
"url": "/ajax/role",
// you may want to pass extra data on the ajax call
"extraData": "name=duncan",
"alertText": "* 此角色名称已被其他人使用",
"alertTextLoad": "* 正在确认,请稍等…"
}