Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pop up a message when users are trying to leave the web page

Status
Not open for further replies.

jianhua

Programmer
Jun 22, 2001
55
US
Hello,

I'm working on the online open enrollment now and it contains several pages or we can say several cfm files. On every page, we have links to link to other sections. I want to alert my users if they are trying to leave the open enrollment pages with the job half way done. How can I do it?

Any suggestion is appreciated!
jianhua
 
you would need to use javascript to detect if the fields are empty, and if so, throw up an alert, and then redirect.

-n
 
Using <cfinput tag has a 'required' field and a 'message' field. If you set required=&quot;yes&quot;, upon Submit, if the field is empty, the message will be displayed. The user will need to fill this field before continuing.
 
noyes99, when people access the page, their current data is displayed, so there are no empty fields. I can set up a flag field, but have no idea of how to detect it. I'm okay if they click the submit button. What if they use the url box to direct the pages other than the open enrollment pages or click the links to access other sections...

My question might not be clear enough. I have code to validate the fields when the form submits. I need something to detect the page. For example, after people access the open enrollment section, if they don't complete the whole process (a couple of pages) and try to leave the open enrollment section (close the window/page or try to access other sections either via the url box or via clicking the links on our navigator bar), an alert box pops up saying &quot;You are leaving the Open Enrollment and your elections are not submitted at this point...&quot;
 
Check out the javascript &quot;onBeforeUnload&quot; event handler or &quot;onunload&quot; handler

thereptilian120x120.gif
 
but keep in mind that &quot;onBeforeUnload&quot; doesn't work on Netscape.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top