[thelist] ASP Conditional Required Fields

aardvark roselli at earthlink.net
Thu Jul 13 13:44:13 CDT 2000


pseudo-code, not perfect, or the bestest approach, but it should 
get you started (i'm doing this as if they were checkboxes to show 
you the instr() function, you can just use basic 'if blank or not value' 
checks on radio buttons):

<%
IF instr(1,Request("ButtonA","ValueA1",1) > 0 THEN
	IF Request("ButtonB") = "" OR Request("ButtonC") = "" THEN
		'do something to indicate a failure
	ELSE
		'let them go on
	END IF
ELSEIF instr(1,Request("ButtonA","ValueA2",1) > 0 THEN
	IF Request("ButtonB") = "" THEN
		'do something to indicate a failure
	ELSE
		'let them go on
	END IF
ELSEIF instr(1,Request("ButtonA","ValueA3",1) > 0 THEN
	IF Request("ButtonC") = "" THEN
		'do something to indicate a failure
	ELSE
		'let them go on
	END IF
ELSE
	'let them go on
END IF
%>

beware of any wrap above...

there are many other ways to do this, but i find that if/else 
statements are easiest to grasp when you're starting out on these 
treks...

> From:  Steve Maxey <smaxey at bcr.com>
> 
> Let's say I have three groups of Radio Buttons, A, B, and C
> 
> A
> button A1
> button A2
> button A3
> button A4
> B
> buttons
> C
> buttons
> 
> A is a required field (that is, at least one button must be chosen for
> the form to be processed; otherwise a warning box sends you back)
> 
> Now I need to set it up so that if button A1 is selected, choosing a
> button in both B and C is required; if A2 is selected, choosing a
> button in B (only) is required; if A3 is selected, a button in C
> (only) is required; and if A4 is selected neither B nor C is 
required.




More information about the thelist mailing list