...

View Full Version : Multiple Onsubmit Functions



Solace
09-16-2005, 01:06 AM
Hello all, I have searched the forums and found posts that seem like they should solve my problem but I still cant get it working.

Basically I am building a form that contains many checkmarks and pick lists. I need to have it so each checkmark is checked, and each pick list has a selection made before a user can submit (annoying I know but its not up to me).

I can get one or the other to work but not all all of them. Any help would be greatly appreciated.


Here is the code.


onsubmit="return validateForm()&& return checkCheckBox(this)">

Then in the <HEAD> I have:


<SCRIPT language="JavaScript" type="text/javascript">
<!--
// Script Source: insighteye.com
function checkCheckBox(f){
if (f.agree.checked == false )
{
alert("You must accept the conditions to continue.");
return false;
}else
return true;
}
//-->
</SCRIPT>


<SCRIPT LANGUAGE="JavaScript">
<!--

function validateForm(){
if(document.form.scouting.selectedIndex==0)
{
alert("Please select a Specialist.");
document.form.scouting.focus();
return false;
}
return true;
}
//-->
</SCRIPT>
<SCRIPT LANGUAGE="JavaScript">
formelement.onsubmit=function(e){
return checkCheckBox(this)&&return validateForm();
};
</SCRIPT>

glenngv
09-16-2005, 07:12 AM
onsubmit="return validateForm() && checkCheckBox(this)"

Canuck WebGeek
09-16-2005, 03:01 PM
why not put all the checks in one validate function?



function validateForm(f) {
if (!f.selectOne.selectedIndex) {
alert('Field One is Mandetory')
return false;
}
else if (!f.checkBoxTwo.checked) {
alert('Field Two is Mandetory')
return false;

}
return true;
}

Solace
09-16-2005, 05:06 PM
Thank you guys so much.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum