window.onload = function(){
/*自定义验证规则(这里自定义了年龄的规则)
FancyForm.vtype({
type: 'age',
fn: function(value){
return value>20 && value<80;
},
text: '请输入80并且大于20的年龄'
});
//设置下拉框数据
var comboData = [
{index:0, country: '中国'},
{index:1, country: '美国'},
{index:1, country: '欧洲'}
];*/
//构造表单
var form = $('#form').FancyForm({
title: '添加角色',
width: 345,
height: 325,
inputWidth: 190,
labelWidth: 60,
url: '<%=path %>/sysRoleController/addRole.do',
params: {
param1: 1,
param2:'string'
},
defaults: {
type: 'string'
},
items: [{
label: '设置编号',
emptyText: '请输入编号',
name: 'roleNo',
valid: {
blank: false,
blankText: '编号不能为空!',
text: '编号不能为空! ',
}
},{
label: '设置角色名',
emptyText: '请输入角色名',
name: 'roleName',
valid: {
blank: false,
blankText: '角色名不能为空!',
text: '角色名不能为空! ',
}
},{
type: 'textarea',
label: '角色描述',
name: 'roleDesc',
height:60
},{
type: 'checkbox',
label: '是否启用',
name: 'flag'
}],
buttons: [{
text: '返回',
handler: function(){
history.go(-1);
}
},{
text: '清除',
handler: function(){
console.log('clear');
form.clear();
}
},{
text: '提交',
handler: function(){
console.log('提交');
form.submit({
params: {
param3: 'Some Values'
},
success: function(result, status, xhr){
console.log('success');
console.log(arguments);
},
error: function(xhr,status,error){
console.log('error');
console.log(arguments);
}
});
}
}],
events: [{
key: function(form, index, value){
}
}]
});
prettyPrint();
};
在里面怎么写鼠标离开事件,判断角色编号,是不是唯一的,(要从数据库查),是用ajax写么?,求大神教