Validation

C

cliveswan

Hi,

Could anyone provide assistance with validation.

I have Q1 (Yes/No)
Q2 - Q10 (Yes/No)


If Q1 is Yes, then at least one of Q2-10 must be yes
If Q1 is No, then all Q2-10 must be No

Can you assign Q2-10 = 0 or 1

then add-up Q2-10

If yes the Q2-20 >= 1
or No then Q2-10 = 0

How would you say this in Java????

Thanks

Clive
 
L

Lew

Hi,

Could anyone provide assistance with validation.

I have Q1 (Yes/No)
Q2 - Q10 (Yes/No)


If Q1 is Yes, then at least one of Q2-10 must be yes
If Q1 is No, then all Q2-10 must be No

Can you assign Q2-10 = 0 or 1

then add-up Q2-10

If yes the Q2-20 >= 1
or No then Q2-10 = 0

How would you say this in Java????

Convert checkbox inputs to boolean (Struts does this for you). Throw the
booleans into an array or List.

boolean isQ1 = checks.get(0);
if ( isQ1 )
{
for ( int ix = 1; ix < checks.size(); ++ix )
{
if ( checks.get(ix) )
{
return VALID;
}
}
return INVALID;
}
else
{
for ( int ix = 1; ix < checks.size(); ++ix )
{
if ( checks.get(ix) )
{
return INVALID;
}
}
return VALID;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,281
Latest member
Pedroaciny

Latest Threads

Top