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

Submit Check Problem

Status
Not open for further replies.

idaryl

Technical User
Nov 10, 2001
156
0
0
US
Hello,
I am using the script below to check my form for errors. It works if I take out the "else alert("All ok"); return false;"[/red] part. But, I really need it in there, where am I going wrong with this?

All I want it to do is check the form then tell me its OK if the fields are filled in...correctly.

-----------------

function contactCheck()
{
if (document.contactform.first_name.value == "")
{
alert("First Name | Problem:\n\nYou forgot to enter\nyour first name\n\nPlease enter it\n\nThis entry is required!.");
document.contactform.first_name.focus();
return false;
}

else if (document.contactform.last_name.value == "")
{
alert("Last Name | Problem:\n\nYou forgot to enter\nyour last name\n\nPlease enter it\n\nThis entry is required!.");
document.contactform.last_name.focus();
return false;
}

else if (document.contactform.submit_by.value.indexOf("@") == -1 ||
document.contactform.submit_by.value == "")
{
alert("Email Address | Problem:\n\nYou forgot to enter\nyour email\n\nPlease enter it\n\nThis entry is required!.");
document.contactform.submit_by.focus();
return false;

else alert("All ok");
return false;

}
} • idaryl
idface.gif
 
function contactCheck()
{
if (document.contactform.first_name.value == "")
{
alert("First Name | Problem:\n\nYou forgot to enter\nyour first name\n\nPlease enter it\n\nThis entry is required!.");
document.contactform.first_name.focus();
return false;
}

else if (document.contactform.last_name.value == "")
{
alert("Last Name | Problem:\n\nYou forgot to enter\nyour last name\n\nPlease enter it\n\nThis entry is required!.");
document.contactform.last_name.focus();
return false;
}

else if (document.contactform.submit_by.value.indexOf("@") == -1 ||
document.contactform.submit_by.value == "")
{
alert("Email Address | Problem:\n\nYou forgot to enter\nyour email\n\nPlease enter it\n\nThis entry is required!.");
document.contactform.submit_by.focus();
return false;

}
else{
alert("All ok");
return false;

}
} -----------------------------------------------------------------
"The difference between 'involvement' and 'commitment' is like an eggs-and-ham breakfast: the chicken was 'involved' - the pig was 'committed'."
- unknown

mikewolf@tst-us.com
 
Hi mWolf00,
yikes, my bad.... I put in the wrong code -this one actually works but I need the alert just the same if all is OK.

sorry about the confusion ;-(



--------------------------------------------
function contactCheck()
{
if (document.contactform.first_name.value == "")
{
alert("First Name | Problem:\n\nYou forgot to enter\nyour first name\n\nPlease enter it\n\nThis entry is required!.");
document.contactform.first_name.focus();
return false;
}

if (document.contactform.last_name.value == "")
{
alert("Last Name | Problem:\n\nYou forgot to enter\nyour last name\n\nPlease enter it\n\nThis entry is required!.");
document.contactform.last_name.focus();
return false;
}

if (document.contactform.submit_by.value.indexOf("@") == -1 ||
document.contactform.submit_by.value == "")
{
alert("Email Address | Problem:\n\nYou forgot to enter\nyour email\n\nPlease enter it\n\nThis entry is required!.");
document.contactform.submit_by.focus();
return false;

}

} • idaryl
idface.gif
 
doh! [sleeping] don't know what I was thinking TA... -----------------------------------------------------------------
"The difference between 'involvement' and 'commitment' is like an eggs-and-ham breakfast: the chicken was 'involved' - the pig was 'committed'."
- unknown

mikewolf@tst-us.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top