Hi there

I have a page with some forms on (the "action" page is a different page), the problem is users sometimes don't spot the forms and leave the page by other means.

(it's a long story as to why they don't spot the forms and submit one of them, but the point is we need to remind them to submit one of the forms if they go to unload the page by any other way)

I plan to use a javascript "alert" with the following message "Oops, you didn't click on one of the submit buttons, is that what you meant to do? If you want to go back and click on of the submit buttons click "cancel" or if you really wanted to leave this page then click "ok".

So far so good.

The problem is how to 'disable' the javascript alert in the event of them submitting one of the forms...


My thoughts are

Option 1: I could add some JS to the submit button such as 'onclick="disable the alert"'

Option 2: I could have a hidden form variable in the page which defaults to zero.

I then would make the function that launches the alert check the value of that variable and only continue if the variable = 0

I would have each of the submit buttons do 'onclick="set the varible to = 1'

- hope that makes sense.


My knowledge of javascript is "beginner" so if anyone could help with how best to tackle this I'd be ever so grateful.

TIA Nick