欢迎光临Software MyZone,有问题可留言或到站点论坛发帖,争取第一时间帮忙解决 || 站点论坛:火龙论坛 || 淘宝小店:应小心的易淘屋 【欢迎大家提建设性意见】

validationEngine ajax

本文为firedragonpzy原创,转载务必在明显处注明:
转载自【Softeware MyZone】原文链接: http://www.firedragonpzy.com.cn/index.php/archives/756


php — inline和submit的ajax验证(包括三个地方需要配置)

1:文件中js配置(除了引入该有的js、css外还需此配置)[js]
$(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//启用回调
});
});[/js]

2:表单:[js]

<form id="form_validate" action="/ajax/rolesubmit" method="post" name="form_validate"><span style="color: #000000; font-family: Arial;"><span style="line-height: normal;"><form id="form_validate" action="/ajax/rolesubmit" method="post" name="form_validate"><input id="roleName" type="text" name="roleName" value="{$roleName}" /></form>[/js]

3:验证:[js]
"ajaxRole": {
"url": "/ajax/role",
// you may want to pass extra data on the ajax call
"extraData": "name=duncan",
"alertText": "* 此角色名称已被其他人使用",
"alertTextLoad": "* 正在确认,请稍等…"
}[/js]

2 条评论

发表评论