Solved

Javascript PopUp message on a form submit

Posted on 2007-12-03
4
1,631 Views
Last Modified: 2012-06-27
I have a form on a php page, and all i simply want is when a user clicks "submit" it brings up  a PopUp message / error.
I have gone through the site and for some reason have not found a simple solution.
So basically, when a user clicks the submit button, I want it to display a popup with a message and two buttons like ...
Are you sure you want to continue?
if "Yes" .... go to this page
if "No" .... close the popup and return to the same page

Thanks!
0
Comment
Question by:Dustballs
4 Comments
 
LVL 12

Accepted Solution

by:
Sinoj Sebastian earned 150 total points
ID: 20397719
<form id="form1" onsubmit="return confirm('Are you sure you want to continue?');" action="<url>">
0
 
LVL 31

Assisted Solution

by:Frosty555
Frosty555 earned 150 total points
ID: 20397885
Hm does it work to put it in the onsubmit of the form? The way I've always done it is in the input button's onclick:

<input onclick="return confirm('Click OK to submit.');" type="submit" name="Submit" value="Submit">

But perhaps sinoj's solution works not only when you click the button, but also when something programatically submits the form or the user hits enter while inside the last textbox of the form. So try his first.
0
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 20397961
@Frosty555

Sinoj's suggestion of doing it in the form tag with the onsubmit event will work.  The "thoughts" you shared in your comment on its benefits are correct.  I recommend doing it in the onsubmit event in the form tag although there is nothing wrong with the way you suggested it.

I hope this helps. :)  Let me know if you have any questions or need more information.

b0lsc0tt
0
 

Author Comment

by:Dustballs
ID: 20398043
I've tried both ways and I think they work the exact same, I don't notice any difference. Both of them will work if the user hits return after entering data in any textbox in the form.
It's a toss of a coin really ;-) so i'll split the points, cheers!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now