Javascript代码:
if (s12.value < s10.value) {
$('<div></div>').appendTo('body')
.html('<div><h6>' + "Out Time is less than In Time. Is that ok??" + '</h6></div>')
.dialog({
modal: true,
title: 'Confirmation',
zIndex: 10000,
autoOpen: true,
width: 'auto',
resizable: true,
buttons: {
Yes: function () {
if (s10.value < s14.value || s14.value < s12.value) {
alertDialog("Time is not between out time and in time.");
} else {
$("#<%=Button1.ClientID%>").submit();
}
$(this).dialog("close");
},
No: function () {
$(this).dialog("close");
}
},
close: function (event, ui) {
$(this).remove();
}
});
< script >
function alertDialog(message) {
$('<div></div>').appendTo('body')
.html('<div><h6>' + message + '</h6></div>')
.dialog({
modal: true,
title: 'Errors',
zIndex: 10000,
autoOpen: true,
width: 'auto',
resizable: true,
buttons: {
Ok: function () {
$(this).dialog("close");
},
},
close: function (event, ui) {
$(this).remove();
}
});
}; < /script>
条件1:if (s12.value < s10.value)
然后显示确认框,说“出时间小于及时。可以吗?”
如果用户选择是,则选择条件2:if (s10.value < s14.value || s14.value < s12.value)
,然后显示警告框
否则提交表格。
问题:它能够显示确认框,但从不等待用户点击是/否,它会自动提交表单。
请帮助。提前致谢。
答案 0 :(得分:0)
你应该创建一个没有打开的对话框
var dialog_var = $('<div></div>').appendTo('body')
.html('<div><h6>' + message + '</h6></div>')
.dialog({
modal: true, title: 'Errors', zIndex: 10000, autoOpen: true,
width: 'auto', resizable: true,
buttons: {
Ok: function () {
$(this).dialog("close");
},
function alertDialog(message) {
$(dialog_var).dialog("open");