JavaScript function:
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();
}
});
};
The first condition:if (s12.value < s10.value)
, prompts a confirmation box with the message "Out Time is less than In Time. Is that ok??"
If the user selects Yes, then check the second condition:
if (s10.value < s14.value || s14.value < s12.value)
, if it's true, display an alert box.
Otherwise, submit the form.
Issue: The form is submitted automatically without waiting for the user to interact with the confirm box.
Requesting assistance. Thank you.