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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form submit confirmation 1

Status
Not open for further replies.

mufka

ISP
Dec 18, 2000
587
US
Is there a way to launch a confirmation pop-up when one hits submit on a form? Basically, I want it to ask "Are you sure you want to submit this form?" with Yes or No. I don't want someone to accidentally hit enter while in the form and have the form submitted.

I've looked at onSubmit but I can't find enough examples to get it to do what I want.
 
You'll need Javascript for this.

You'll need a small function to present the pop up and check which button was pressed.

Something like this:

[green]Place this first part between the <header> tags of your document.[/green]
Code:
<script language="JavaScript">
function confirm_submit(){
var answer = confirm ("Are you sure you want to submit the form?");
return answer;
} 
[green]\\The line above creates the confirmation dialog, and returns the value of the answer to the form.[/green]
</script>

Then in your form code:

Code:
<form onSubmit="return confirm_submit();" ... >
...

For any other JS questions you can ask in forum216


----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top