473,399 Members | 3,038 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,399 software developers and data experts.

Required Fields and Warning Boxes

Hi,

I have a form with multiple fields that confirmed before the form is
submitted (ex. email field needs to be completed before the form can
be submitted). Once the required fields are completed, I want a final
warning box to appear asking the user "are you sure you want to make
these changes?" I'm having trouble getting the function to work
correctly. Here's the problem I've encountered:

First Script: this one lets me enter an email into an empty email
field and shows the confirmation box but the information in the form
is updated regardless of whether I click OK or Cancel.

function page_check()
{
if (check(document.form.txt_EMail.value,true))
{
if ((document.form.txt_EMail.value!="") &&
(check(document.form.txt_EMail.value,false)))
document.form.submit();
else
{
if (document.form.txt_EMail.value=='')
alert('Please enter an email.');
return;
}

if(confirm("Are you sure you want to upload this file?"))
{
document.form.page_check()
return false;
}
}
}

Second Script: When I create a separate function with "are you sure
you..." warning similar to this:

function page_check()
{ if(confirm("Are you sure you want to upload this file?"))
{
document.form.page_check()
return false;
}
}else
return true;
}

it does not prompt me to complete the email field. It goes straight
to the warning, "are you sure..." However, if I click Cancel, then it
does not update, and if I click OK it updates.

Any suggestions on how to fix this script so that I can keep the enter
email prompt AND the warning prompt?

Any help is very much appreciated. Thanks in advance.

Jun 27 '08 #1
5 1612
On Apr 15, 5:28 pm, Cubicle Intern <vyts...@gmail.comwrote:
Hi,

I have a form with multiple fields that confirmed before the form is
submitted (ex. email field needs to be completed before the form can
be submitted). Once the required fields are completed, I want a final
warning box to appear asking the user "are you sure you want to make
these changes?" I'm having trouble getting the function to work
correctly. Here's the problem I've encountered:

First Script: this one lets me enter an email into an empty email
field and shows the confirmation box but the information in the form
is updated regardless of whether I click OK or Cancel.

function page_check()
{
if (check(document.form.txt_EMail.value,true))
{
if ((document.form.txt_EMail.value!="") &&
(check(document.form.txt_EMail.value,false)))
document.form.submit();
else
{
if (document.form.txt_EMail.value=='')
alert('Please enter an email.');
return;
}

if(confirm("Are you sure you want to upload this file?"))
{
document.form.page_check()
return false;
}
}

}

Second Script: When I create a separate function with "are you sure
you..." warning similar to this:

function page_check()
{ if(confirm("Are you sure you want to upload this file?"))
{
document.form.page_check()
return false;
}
}else
return true;

}

it does not prompt me to complete the email field. It goes straight
to the warning, "are you sure..." However, if I click Cancel, then it
does not update, and if I click OK it updates.

Any suggestions on how to fix this script so that I can keep the enter
email prompt AND the warning prompt?

Any help is very much appreciated. Thanks in advance.
Let me know if this is of any use. Specifically, I would access the
form field via "document.forms[0]" instead of "document.form".

Note that onSubmit wants a true or false value from the returning
function. If onSubmit receives false, form.submit never fires (you
don't have to explicitly submit within your function call. When
onSubmit receives true, the current values entered in the form will be
sent to the server.

<html>
<head>
<script>
function errorfree (initialValue,errorValue,msg) {
var err = (initialValue == errorValue);
if (err) if( msg || '' != '' ) alert (msg);
return (! err);
}
</script>
</head>
<body>
<form method="GET" action="" onSubmit="return errorfree
(document.forms[0].txt_EMail.value || '','','Please enter an
email.')">
<input name="txt_EMail" id="txt_EMail" />
<input type="submit" />
</form>
</body>
</html>

-Tom Woz
Jun 27 '08 #2
On Apr 15, 9:19*pm, tomtom.wozn...@gmail.com wrote:
On Apr 15, 5:28 pm, Cubicle Intern <vyts...@gmail.comwrote:


Hi,
I have a form with multiple fields that confirmed before the form is
submitted (ex. email field needs to be completed before the form can
be submitted). *Once the required fields are completed, I want a final
warning box to appear asking the user "are you sure you want to make
these changes?" *I'm having trouble getting the function to work
correctly. *Here's the problem I've encountered:
First Script: this one lets me enter an email into an empty email
field and shows the confirmation box but the information in the form
is updated regardless of whether I click OK or Cancel.
function page_check()
{
if (check(document.form.txt_EMail.value,true))
* * * * {
* * * * * * * * * * * * if ((document.form.txt_EMail.value!="") &&
(check(document.form.txt_EMail.value,false)))
* * * * * * * * * * * * document.form.submit();
* * * * * * * * * * * * else
* * * * * * * * * * * * * * * * {
* * * * * * * * * * * * * * * * * * * * if (document.form.txt_EMail.value=='')
* * * * * * * * * * * * * * * * * * * * * * * * alert('Please enter an email.');
* * * * * * * * * * * * * * * * * * * * * * * * * * * * return;
* * * * * * * * * * * * * * * * }
* if(confirm("Are you sure you want to upload this file?"))
* * * * * * * * * * * * {
* * * * * * * * * * * * document.form.page_check()
* * * * * * * * * * * * return false;
* * * * * * * * * * * * }
* * * * }
}
Second Script: When I create a separate function with *"are you sure
you..." warning similar to this:
function page_check()
{ *if(confirm("Are you sure you want to upload this file?"))
* * * * * * * * * * * * {
* * * * * * * * * * * * document.form.page_check()
* * * * * * * * * * * * return false;
* * * * * * * * * * * * }
* * * * }else
* * * * * * * * * return true;
}
*it does not prompt me to complete the email field. *It goes straight
to the warning, "are you sure..." However, if I click Cancel, then it
does not update, and if I click OK it updates.
Any suggestions on how to fix this script so that I can keep the enter
email prompt AND the warning prompt?
Any help is very much appreciated. *Thanks in advance.

Let me know if this is of any use. *Specifically, I would access the
form field via "document.forms[0]" instead of "document.form".

Note that onSubmit wants a true or false value from the returning
function. *If onSubmit receives false, form.submit never fires (you
don't have to explicitly submit within your function call. *When
onSubmit receives true, the current values entered in the form will be
sent to the server.

<html>
<head>
* <script>
* * function errorfree (initialValue,errorValue,msg) {
* * * var err = (initialValue == errorValue);
* * * if (err) if( msg || '' != '' ) alert (msg);
* * * return (! err);
* * }
* </script>
</head>
<body>
* <form method="GET" action="" onSubmit="return errorfree
(document.forms[0].txt_EMail.value || '','','Please enter an
email.')">
* * <input name="txt_EMail" id="txt_EMail" />
* * <input type="submit" />
* </form>
</body>
</html>

-Tom Woz- Hide quoted text -

- Show quoted text -

Hi,

Thanks for the help but unfortunately it didn't work as well as I
hoped it would. Would you be able to suggest how to apply multiple if/
else statements to the function above?

tyv
Jun 27 '08 #3
On Apr 15, 9:19*pm, tomtom.wozn...@gmail.com wrote:
On Apr 15, 5:28 pm, Cubicle Intern <vyts...@gmail.comwrote:


Hi,
I have a form with multiple fields that confirmed before the form is
submitted (ex. email field needs to be completed before the form can
be submitted). *Once the required fields are completed, I want a final
warning box to appear asking the user "are you sure you want to make
these changes?" *I'm having trouble getting the function to work
correctly. *Here's the problem I've encountered:
First Script: this one lets me enter an email into an empty email
field and shows the confirmation box but the information in the form
is updated regardless of whether I click OK or Cancel.
function page_check()
{
if (check(document.form.txt_EMail.value,true))
* * * * {
* * * * * * * * * * * * if ((document.form.txt_EMail.value!="") &&
(check(document.form.txt_EMail.value,false)))
* * * * * * * * * * * * document.form.submit();
* * * * * * * * * * * * else
* * * * * * * * * * * * * * * * {
* * * * * * * * * * * * * * * * * * * * if (document.form.txt_EMail.value=='')
* * * * * * * * * * * * * * * * * * * * * * * * alert('Please enter an email.');
* * * * * * * * * * * * * * * * * * * * * * * * * * * * return;
* * * * * * * * * * * * * * * * }
* if(confirm("Are you sure you want to upload this file?"))
* * * * * * * * * * * * {
* * * * * * * * * * * * document.form.page_check()
* * * * * * * * * * * * return false;
* * * * * * * * * * * * }
* * * * }
}
Second Script: When I create a separate function with *"are you sure
you..." warning similar to this:
function page_check()
{ *if(confirm("Are you sure you want to upload this file?"))
* * * * * * * * * * * * {
* * * * * * * * * * * * document.form.page_check()
* * * * * * * * * * * * return false;
* * * * * * * * * * * * }
* * * * }else
* * * * * * * * * return true;
}
*it does not prompt me to complete the email field. *It goes straight
to the warning, "are you sure..." However, if I click Cancel, then it
does not update, and if I click OK it updates.
Any suggestions on how to fix this script so that I can keep the enter
email prompt AND the warning prompt?
Any help is very much appreciated. *Thanks in advance.

Let me know if this is of any use. *Specifically, I would access the
form field via "document.forms[0]" instead of "document.form".

Note that onSubmit wants a true or false value from the returning
function. *If onSubmit receives false, form.submit never fires (you
don't have to explicitly submit within your function call. *When
onSubmit receives true, the current values entered in the form will be
sent to the server.

<html>
<head>
* <script>
* * function errorfree (initialValue,errorValue,msg) {
* * * var err = (initialValue == errorValue);
* * * if (err) if( msg || '' != '' ) alert (msg);
* * * return (! err);
* * }
* </script>
</head>
<body>
* <form method="GET" action="" onSubmit="return errorfree
(document.forms[0].txt_EMail.value || '','','Please enter an
email.')">
* * <input name="txt_EMail" id="txt_EMail" />
* * <input type="submit" />
* </form>
</body>
</html>

-Tom Woz- Hide quoted text -

- Show quoted text -
So I modified my script but whenever I click Cancel or OK it still
updates everything in the form. Any suggestions are very much
appreciated. This is what it looks like now:

function page_check_pwd()
{
if (check_pwd(document.frm.txt_EMail.value,true))
{
if ((document.frm.txt_EMail.value!="") &&
(check_pwd(document.form.txt_EMail.value,false)))
document.form.submit();
else
{
if (document.frm.txt_EMail.value=="")
alert('Please enter an email.');
return false;
}

if(confirm("Are you sure you want to make these changes?"))
{
document.form.submit()
return true;
} else
return false;
}
}
Jun 27 '08 #4
On Apr 16, 3:44 pm, Cubicle Intern <vyts...@gmail.comwrote:
On Apr 15, 9:19 pm, tomtom.wozn...@gmail.com wrote:
On Apr 15, 5:28 pm, Cubicle Intern <vyts...@gmail.comwrote:
Hi,
I have a form with multiple fields that confirmed before the form is
submitted (ex. email field needs to be completed before the form can
be submitted). Once the required fields are completed, I want a final
warning box to appear asking the user "are you sure you want to make
these changes?" I'm having trouble getting the function to work
correctly. Here's the problem I've encountered:
First Script: this one lets me enter an email into an empty email
field and shows the confirmation box but the information in the form
is updated regardless of whether I click OK or Cancel.
function page_check()
{
if (check(document.form.txt_EMail.value,true))
{
if ((document.form.txt_EMail.value!="") &&
(check(document.form.txt_EMail.value,false)))
document.form.submit();
else
{
if (document.form.txt_EMail.value=='')
alert('Please enter an email.');
return;
}
if(confirm("Are you sure you want to upload this file?"))
{
document.form.page_check()
return false;
}
}
}
Second Script: When I create a separate function with "are you sure
you..." warning similar to this:
function page_check()
{ if(confirm("Are you sure you want to upload this file?"))
{
document.form.page_check()
return false;
}
}else
return true;
}
it does not prompt me to complete the email field. It goes straight
to the warning, "are you sure..." However, if I click Cancel, then it
does not update, and if I click OK it updates.
Any suggestions on how to fix this script so that I can keep the enter
email prompt AND the warning prompt?
Any help is very much appreciated. Thanks in advance.
Let me know if this is of any use. Specifically, I would access the
form field via "document.forms[0]" instead of "document.form".
Note that onSubmit wants a true or false value from the returning
function. If onSubmit receives false, form.submit never fires (you
don't have to explicitly submit within your function call. When
onSubmit receives true, the current values entered in the form will be
sent to the server.
<html>
<head>
<script>
function errorfree (initialValue,errorValue,msg) {
var err = (initialValue == errorValue);
if (err) if( msg || '' != '' ) alert (msg);
return (! err);
}
</script>
</head>
<body>
<form method="GET" action="" onSubmit="return errorfree
(document.forms[0].txt_EMail.value || '','','Please enter an
email.')">
<input name="txt_EMail" id="txt_EMail" />
<input type="submit" />
</form>
</body>
</html>
-Tom Woz- Hide quoted text -
- Show quoted text -

So I modified my script but whenever I click Cancel or OK it still
updates everything in the form. Any suggestions are very much
appreciated. This is what it looks like now:

function page_check_pwd()
{
if (check_pwd(document.frm.txt_EMail.value,true))
{
if ((document.frm.txt_EMail.value!="") &&
(check_pwd(document.form.txt_EMail.value,false)))
document.form.submit();
else
{
if (document.frm.txt_EMail.value=="")
alert('Please enter an email.');
return false;
}

if(confirm("Are you sure you want to make these changes?"))
{
document.form.submit()
return true;
} else
return false;

}
}
I cleaned up your latest code. Let me know if this is what you're
looking for.

function page_check_pwd() {
var result = false; // only set to true when validated.
if (check_pwd(document.frm.txt_EMail.value,true)) {
if ((document.frm.txt_EMail.value!="") &&
(check_pwd(document.form.txt_EMail.value,false))) {
if (confirm("Are you sure you want to make these changes?")) {
result = true;
}
} else {
if (document.frm.txt_EMail.value=="") {
alert('Please enter an email.');
}
}
}
return result;
}

-Tom Woz
Jun 27 '08 #5
On Apr 17, 11:36*am, tomtom.wozn...@gmail.com wrote:
On Apr 16, 3:44 pm, Cubicle Intern <vyts...@gmail.comwrote:


On Apr 15, 9:19 pm, tomtom.wozn...@gmail.com wrote:
On Apr 15, 5:28 pm, Cubicle Intern <vyts...@gmail.comwrote:
Hi,
I have a form with multiple fields that confirmed before the form is
submitted (ex. email field needs to be completed before the form can
be submitted). *Once the required fields are completed, I want a final
warning box to appear asking the user "are you sure you want to make
these changes?" *I'm having trouble getting the function to work
correctly. *Here's the problem I've encountered:
First Script: this one lets me enter an email into an empty email
field and shows the confirmation box but the information in the form
is updated regardless of whether I click OK or Cancel.
function page_check()
{
if (check(document.form.txt_EMail.value,true))
* * * * {
* * * * * * * * * * * * if ((document.form.txt_EMail.value!="") &&
(check(document.form.txt_EMail.value,false)))
* * * * * * * * * * * * document.form.submit();
* * * * * * * * * * * * else
* * * * * * * * * * * * * * * * {
* * * * * * * * * * * * * * * * * * * * if (document.form.txt_EMail.value=='')
* * * * * * * * * * * * * * * * * * * * * * * * alert('Please enter an email.');
* * * * * * * * * * * * * * * * * * * * * * * * * * * * return;
* * * * * * * * * * * * * * * * }
* if(confirm("Are you sure you want to upload this file?"))
* * * * * * * * * * * * {
* * * * * * * * * * * * document.form.page_check()
* * * * * * * * * * * * return false;
* * * * * * * * * * * * }
* * * * }
}
Second Script: When I create a separate function with *"are you sure
you..." warning similar to this:
function page_check()
{ *if(confirm("Are you sure you want to upload this file?"))
* * * * * * * * * * * * {
* * * * * * * * * * * * document.form.page_check()
* * * * * * * * * * * * return false;
* * * * * * * * * * * * }
* * * * }else
* * * * * * * * * return true;
}
*it does not prompt me to complete the email field. *It goes straight
to the warning, "are you sure..." However, if I click Cancel, then it
does not update, and if I click OK it updates.
Any suggestions on how to fix this script so that I can keep the enter
email prompt AND the warning prompt?
Any help is very much appreciated. *Thanks in advance.
Let me know if this is of any use. *Specifically, I would access the
form field via "document.forms[0]" instead of "document.form".
Note that onSubmit wants a true or false value from the returning
function. *If onSubmit receives false, form.submit never fires (you
don't have to explicitly submit within your function call. *When
onSubmit receives true, the current values entered in the form will be
sent to the server.
<html>
<head>
* <script>
* * function errorfree (initialValue,errorValue,msg) {
* * * var err = (initialValue == errorValue);
* * * if (err) if( msg || '' != '' ) alert (msg);
* * * return (! err);
* * }
* </script>
</head>
<body>
* <form method="GET" action="" onSubmit="return errorfree
(document.forms[0].txt_EMail.value || '','','Please enter an
email.')">
* * <input name="txt_EMail" id="txt_EMail" />
* * <input type="submit" />
* </form>
</body>
</html>
-Tom Woz- Hide quoted text -
- Show quoted text -
So I modified my script but whenever I click Cancel or OK it still
updates everything in the form. *Any suggestions are very much
appreciated. *This is what it looks like now:
function page_check_pwd()
{
* * * * if (check_pwd(document.frm.txt_EMail.value,true))
* * * * {
* * * * * * * * * * * * if ((document.frm.txt_EMail.value!="") &&
(check_pwd(document.form.txt_EMail.value,false)))
* * * * * * * * * * * * document.form.submit();
* * * * * * * * * * * * else
* * * * * * * * * * * * * * * * {
* * * * * * * * * * * * * * * * * * * * if (document.frm.txt_EMail.value=="")
* * * * * * * * * * * * * * * * * * * * * * * * alert('Please enter an email.');
* * * * * * * * * * * * * * * * * * * * * * * * * * * * return false;
* * * * * * * * * * * * * * * * }
* if(confirm("Are you sure you want to make these changes?"))
* * {
* * document.form.submit()
* * return true;
* * * * } else
* * * * return false;
}
}

I cleaned up your latest code. *Let me know if this is what you're
looking for.

* function page_check_pwd() {
* * var result = false; // only set to true when validated.
* * if (check_pwd(document.frm.txt_EMail.value,true)) {
* * * if ((document.frm.txt_EMail.value!="") &&
(check_pwd(document.form.txt_EMail.value,false))) {
* * * * if (confirm("Are you sure you want to make these changes?")) {
* * * * * result = true;
* * * * }
* * * } else {
* * * * if (document.frm.txt_EMail.value=="") {
* * * * * alert('Please enter an email.');
* * * * }
* * * }
* * }
* * return result;
* }

-Tom Woz- Hide quoted text -

- Show quoted text -
Hi,

I played around with the code a little bit but I still can't get the
warning box to work. Cancel works but when I click OK, nothing
happens (Basically, the opposite problem from what I have before).
Thanks for any additional help.

tyv

Jun 27 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: swingingming | last post by:
Hi, I made a form based on one table that has several required fields. If in the form, I leave some of them blank and close the form using 'X', I get 2 warning messages, 1st is "... field is...
2
by: RICHARD BROMBERG | last post by:
I am using Access 200. I have a form which includes text boxes L1, L2 and L3 And a table tblGrades with number fields L1, L2 and L3
1
by: foothills bhc | last post by:
I have a problem with verifying content of controls on a form before closing the form or moving to the next form "record" (i.e., when moving to the next row of my form's record source). HERE'S THE...
2
by: Neo Geshel | last post by:
Greetings, I have a form with a telephone field. It is very specific, as it has four text boxes - the country code, area code, prefix and suffix. I can validate each of them individually, but...
1
by: commodityintelligence | last post by:
Greetings, I am merging a series of different tables into one query to export decision-making information. I have some architecture issues I need to ask for help on. I have no programming...
1
by: KMEscherich | last post by:
Using Access '97 Hi there, am wondering if there is a way to have a CLOSE button on the form and have it NOT CLOSE the form unless all the REQUIRED controls have an entry. I have 3 items I...
8
by: Wingot | last post by:
Hey, I have a program I am trying to write using Visual C#, SQL Server 2005/2008, and Visual Studio 2008, and one part of it includes a Schema called Client. Inside this schema, three tables...
3
by: ryan.paquette | last post by:
In the table there are 2 fields in which I wish to limit (i.e. No Duplicates) Although I do not want to limit them to "No Duplicates" separately. I need them to be limited to "No Duplicates" as...
0
by: Ledmark | last post by:
I had posted a question asking for help with printing only required fields on a form - both Sierra7 and Denburt answered me and gave me valuable information. I had to make it a little simpler to get...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.