C
Cubicle Intern
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.
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.