ligerui 弹出层用validate印证,为什么不起作用
1个回答
展开全部
他那个按钮是在表单外的,不是在表单内,并且div模拟,触发验证事件需要点击type=submit按钮才行
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script src="App/Scripts/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
<script src="App/lib/jquery-validation/jquery.validate.min.js" type="text/javascript"></script>
<script src="App/lib/jquery-validation/messages_cn.js" type="text/javascript"></script>
<script src="App/lib/ligerUI/js/ligerui.min.js" type="text/javascript"></script>
</head>
<body>
<script>
function formChk() {
$("#mainform").validate({
errorPlacement: function (error, element) {
error.insertAfter(element);
},
rules: { Name: { required: true }, Pwd: { required: true, digits: true} },
messages: { Name: { required: "用户名" }, Pwd: { required: "密码", digits: "数字"} }, debug: true,
invalidHandler: function () {
alert('失败');
},
submitHandler: function () {
alert("成功");
}
});
}
function ShowWindow() {
$("#mainform").ligerForm({
inputwidth: 150,
fields: [{ name: 'Id', type: 'hidden' },
{ display: '姓名', name: 'Name', width: 150, type: 'text' },
{ display: '密码', name: 'Pwd', width: 150, type: 'text'}
]
});
formChk();//注册验证事件
detailWin = $.ligerDialog.open({
target: $("#detail"),
width: 595, height: 460, top: 80, title: "标题", //240
buttons: [
//{ text: '保存', onclick: function () { formChk();} },//这个不需要了,点击不会触发验证事件
{ text: '取消', onclick: function () { detailWin.hide(); } }
]
});
}
</script>
<div id="detail" ><a href="#" onclick="ShowWindow()">
jkjkjkj</a><form id="mainform" method="post"><
input type="submit" value="提交"/></form></div>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script src="App/Scripts/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
<script src="App/lib/jquery-validation/jquery.validate.min.js" type="text/javascript"></script>
<script src="App/lib/jquery-validation/messages_cn.js" type="text/javascript"></script>
<script src="App/lib/ligerUI/js/ligerui.min.js" type="text/javascript"></script>
</head>
<body>
<script>
function formChk() {
$("#mainform").validate({
errorPlacement: function (error, element) {
error.insertAfter(element);
},
rules: { Name: { required: true }, Pwd: { required: true, digits: true} },
messages: { Name: { required: "用户名" }, Pwd: { required: "密码", digits: "数字"} }, debug: true,
invalidHandler: function () {
alert('失败');
},
submitHandler: function () {
alert("成功");
}
});
}
function ShowWindow() {
$("#mainform").ligerForm({
inputwidth: 150,
fields: [{ name: 'Id', type: 'hidden' },
{ display: '姓名', name: 'Name', width: 150, type: 'text' },
{ display: '密码', name: 'Pwd', width: 150, type: 'text'}
]
});
formChk();//注册验证事件
detailWin = $.ligerDialog.open({
target: $("#detail"),
width: 595, height: 460, top: 80, title: "标题", //240
buttons: [
//{ text: '保存', onclick: function () { formChk();} },//这个不需要了,点击不会触发验证事件
{ text: '取消', onclick: function () { detailWin.hide(); } }
]
});
}
</script>
<div id="detail" ><a href="#" onclick="ShowWindow()">
jkjkjkj</a><form id="mainform" method="post"><
input type="submit" value="提交"/></form></div>
</body>
</html>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询