473,395 Members | 1,689 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Form Button Confirmation

18
Need: I have a form. When the user clicks "submit", I need a dialog box to say "Are you finished?" Then I need the Yes/OK button to submit and No/Cancel button to do nothing. Eventually I'll add more validation, but I can handle everything other than how submission would be controlled in a JavaScript environment.

My guess: I'll probably have to add a button to the form that says "submit" (but no actual submit button anywhere). The onclick would call a function containing (pseudo code) if (confirm("text...) submit form xyz, else nothing

Please let me know if I'm on the right track and how to submit the form via JavaScript. If instead I need to include a submit button, let me know how I would be able to "interrupt" it if the user clicked cancel. :-) Thanks.
Jun 26 '08 #1
3 1371
gits
5,390 Expert Mod 4TB
yes ... you are definitly on the right track ... use a button or the form's onsubmit-handler to call the code you have in mind already. in case you use the button you may use the submit() method, in case you want to use the onsubmit-handler just return true or false from there ...

kind regards
Jun 26 '08 #2
Danigan
18
Thanks. I appreciate the help. I'm going to try this:

onSubmit="return validateForm(this)"


Expand|Select|Wrap|Line Numbers
  1. function validateForm(frmObj) {
  2.  
  3. // do form validation here using frmObj
  4. // any validation failures, show alert and return false
  5.  
  6. // if form has been validated, confirm submission using:
  7. var answer = confirm("Ready to submit?")
  8.  if (answer) {
  9.    return true;
  10.  }
  11.  else {
  12.    return false;
  13.  }
  14. }
Jun 26 '08 #3
gits
5,390 Expert Mod 4TB
this should work ;) ... just a note to minify the lines of code:

Expand|Select|Wrap|Line Numbers
  1. function validateForm(frmObj) {
  2.     // do form validation here using frmObj
  3.     // any validation failures, show alert and return false
  4.  
  5.     // if form has been validated, confirm submission using
  6.     return (confirm('Ready to submit?'));
  7. }
  8.  
kind regards
Jun 27 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Calvin | last post by:
Hi, Envronment: IIS 5 on W2k sp3 Problem: I'm using a Form and when Submitted, will display a confirmation page. The confirmation page is simply a Form with an OK button. I want the browser...
5
by: Codeman II | last post by:
Hi there, I am building a form where the user must upload a picture and fill in his details. Now I have a problem as all of this is on the same form. How will I be able to have the Browse...
3
by: D. Shane Fowlkes | last post by:
Sorry for the length of this post. I have created a rather complex form which has a header/line item (parent and child records) structure. It's for an intranet. A screenshot can be seen here: ...
3
by: Bill | last post by:
I'm using the POST method to submit a simple form html page with yes/no and checkbox fields to an asp response page which stores the values in a new dim string, then uses it to build a new table...
16
by: whyyyy | last post by:
The script below works fine if the form is filled out and submitted. But a (blank) e-mail is sent whenever the page loads, even when the form is not submitted. I would like to receive the e-mail...
0
by: bay_dar | last post by:
I have an ASP.NET application with vb that I would like to use a confirmation box with, but only if certain conditions are met. In my case I would only want this msgbox to show up if a user entered...
12
by: colt28 | last post by:
Ok so I found an ajax contact form script but i can't get the b****** to work. I made a bunch of alterations to it and it didn't work so i replaced everything with the original and it still didn't...
5
by: jmartmem | last post by:
Greetings, I have built an Update Record Form in an ASP page. This form contains a number of fields, such as text boxes and menus, to name a few. Upon clicking the 'submit' button, I want the...
4
by: John Straumann | last post by:
Hi all: I have an ASP.NET form that submits info to the server, but the customer wants a confirmation window to open when the user clicks "Submit", and then the user would have to click "OK" on...
8
by: nargis2009 | last post by:
Hi, I have been encountering problems with my web page which is supposed to send email, and wondered if anybody can help find error. Initially I had all codes in one page and on click of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.