0

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)然后显示确认框说“Out Time小于In Time。可以吗??”

如果用户选择是,则条件 2:if (s10.value < s14.value || s14.value < s12.value)然后显示警报框

否则提交表格。

问题:它能够显示确认框,但从不等待用户点击是/否,它会自动提交表单。

请帮忙。提前致谢。

4

1 回答 1

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");
于 2013-10-02T19:20:04.647 回答