Solved

Javascript PopUp message on a form submit

Posted on 2007-12-03
4
1,629 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

744 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

12 Experts available now in Live!

Get 1:1 Help Now