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

Help - How Should I Code This Form Validation?

Status
Not open for further replies.

thainjm

Technical User
Mar 11, 2002
12
0
0
GB
I want to approve a user's form (i.e. send if off for processing) if they meet criteria 1 & 2 or they meet criteria 1 & 3 or they meet criteria 1 & 4.

In each case the answers are provided by radio buttons, the first option of which is YES and the second of which is NO.

I'm getting a bit confused with my brackets I think.

Here's the code....

if((!document.details.k_Permanent_option_amendments_required[0].checked &&
!document.details.m_Member_of_Systems_Development0].checked) || (!document.details.j_Permanent_registry_changes_required[0] && !document.details.m_Member_of_Systems_Development[0].checked) || (!document.details.l_Member_of_official_help_desk[0] &&
!document.details.m_Member_of_Systems_Development[0].checked))
{
alert('Fail : You don't meet the Criteria');
return false;

}

Hope you can help.

Thanks.

JT
 
if (document.details.m_Member_of_Systems_Development0].checked)
{
if
(document.details.k_Permanent_option_amendments_required[0].checked) ||
(document.details.j_Permanent_registry_changes_required[0].checked) ||
(document.details.l_Member_of_official_help_desk[0].checked)

{
alert('Job Done')
return true;
}
}
else
{
alert('Fail : You don't meet the Criteria');
return false;
}


hope this works for you.
p.s. a few if statements were missing the .checked on the end.

Mark
 
oops

forgot to put

{
alert('Job Done')
return true;
}
-> else
-> {
-> alert('Fail : You don't meet the Criteria');
-> return false;
-> }

}
else
{
alert('Fail : You don't meet the Criteria');
return false;
}


Mark
 
Thanks Mark. I'd spotted the missing .checked bits and added them in already without any luck.

I'm just trying your solution without joy so far (syntax errors). Think I might be getting confused trying to include your amendment. Any chance you could post the whole code in a oner.

Densely yours,

JT
 
Aaah, got it!

Needed double round brackets at the start and end of the IF (blah or blah or blah))

Cheers Mark.

JT
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top