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

prevent unwanted box appearing..

Status
Not open for further replies.

Jon99

MIS
Feb 17, 1999
23
US
I have some code on a form. onSubmit check for email address and if it doesn't find one returns false to prevent the form submitting. The problem is that when you click ok or cancel on the alert box "false" or "true" pops up as an alert. How do I stop this?

function email_check()
{
if(document.input.field_1a.value == "")
{
alert(confirm("You must enter your email address"));
goFocus();
return false;
}

else {
return true;
}
}

Thanks
Jon
 
confirm(anything) already opens a popup, asking a question, and it returns either true or false
so you don't need to alert(confirm(something)) !!!!! it'll open a pop up with true, or false ... !
change it to
function email_check()
{
    if(document.input.field_1a.value == "")    
    {        
        confirm("You must enter your email address");    
        goFocus();
        return false;
    }    
return true;
}
 
One way to stop it would be to change the alert(confirm("You must enter your email address")); line to:
alert("You must enter your email address");
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top