T
Tom v
My site uses forms extensively and I would like to implement a feature
that if a user enters data and then tries to navigate away from site a
warning message is displayed. I searched and found the following
function that gives the warning message all the time. I need to
figure out how to activate it only if a key is pressed in the form and
also to not display it if the user submits the button. Thanks for
your help!
(window.onbeforeunload = function (evt) {
if (!evt) {
evt = window.event;
}
if (evt) {
evt.returnValue = 'Are you sure you want to leave this page?';
return evt.returnValue;
}
}
that if a user enters data and then tries to navigate away from site a
warning message is displayed. I searched and found the following
function that gives the warning message all the time. I need to
figure out how to activate it only if a key is pressed in the form and
also to not display it if the user submits the button. Thanks for
your help!
(window.onbeforeunload = function (evt) {
if (!evt) {
evt = window.event;
}
if (evt) {
evt.returnValue = 'Are you sure you want to leave this page?';
return evt.returnValue;
}
}