Jump to content

onsubmit event - IF statements not flowing, returns true early


liquinas

Recommended Posts

Having a bit of a brain fart here. This function is triggered on form submit, which works just fine and fires off heylisten(); if none of the IFs return false. The problem is that once I get to the multiple condition IF statements (the one that checks for specialty8), if the condition doesn't apply because specialty8 is not checked, it returns true and submits the form instead of continuing on to the next IF statement below it. Any help appreciated.

 

function validate(frm)
{
if (frm.type[frm.type.selectedIndex].value == "")
{
	joff();
	alert("You must specify the type of person.");
	return false;
}

if (frm.fname.value == "")
{
	joff();
	alert("You must provide a first name.");
	return false;
}

if (frm.lname.value == "")
{
	joff();
	alert("You must provide a last name.");
	return false;
}

if ((frm.specialty8.checked == true) && (frm.otherspecialty.value == ""))
{
	joff();
	alert("If you select \"Other\" you must enter a description.");
	return false;
} 

if ((frm.modality11.checked == true) && (frm.othermodality.value == ""))
{
	joff();
	alert("If you select \"Other\" you must enter a description.");
	return false;
}

if ((frm.service8.checked == true) && (frm.otherservice.value == ""))
{
	joff();
	alert("If you select \"Other\" you must enter a description.");
	return false;
}

if ((frm.payment0.checked == false) && (frm.payment1.checked == false) && (frm.payment2.checked == false))
{
	joff();
	alert("You must select a payment type.");
	return false;
}
heylisten();
}
//-->
</script>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.