I think it is a very simple way.
var x = confirm("Are you sure you want to submit?");
if (x) {
if (navigator.onLine == true) {
return true;
} else {
alert('Internet connection is lost');
return false;
}
}
else {
return false;
}