Connecting Tech Pros Worldwide Forums | Help | Site Map

ColdFusion Form - Interdependent validation

Newbie
 
Join Date: Jan 2008
Posts: 2
#1: Jan 10 '08
Hello,

I have what appears to be a very simple problem, but I just can't seem to get it to work properly! Here's the issue: I have an html based form that uses a little bit of coldfusion to send the form contents to a specific e-mail. However, if an input called "Priority" is checked, then the next field "Approved By" must be required. If the "Priority" is not checked, then approved by is not required. Here's the base code, without any validation. Can anyone help?

INPUT TYPE="Checkbox" value="Yes" name="priority" SIZE=5 >
High Priority<br>
Approved By<CFINPUT TYPE="text" name="approvedBy" SIZE=30 >

Thanks in advance!

Newbie
 
Join Date: Jan 2008
Posts: 4
#2: Jan 11 '08

re: ColdFusion Form - Interdependent validation


Quote:

Originally Posted by pburkhart

Hello,

I have what appears to be a very simple problem, but I just can't seem to get it to work properly! Here's the issue: I have an html based form that uses a little bit of coldfusion to send the form contents to a specific e-mail. However, if an input called "Priority" is checked, then the next field "Approved By" must be required. If the "Priority" is not checked, then approved by is not required. Here's the base code, without any validation. Can anyone help?

INPUT TYPE="Checkbox" value="Yes" name="priority" SIZE=5 >
High Priority<br>
Approved By<CFINPUT TYPE="text" name="approvedBy" SIZE=30 >

Thanks in advance!

Hi,

In the above case you can use the div tag, using div tag you can able to show & hide the controls according to your requirement.

Please try this out, you can definetely do that.

Regards,
Moorthy
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#3: Jan 11 '08

re: ColdFusion Form - Interdependent validation


To add Coldfusion validation for this, check that the checkbox is defined:
Expand|Select|Wrap|Line Numbers
  1. <cfif not IsDefined("Form.priority")>
  2.     <!--- text box validation for Approved by field here... --->
  3. </cfif>
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#4: Jan 11 '08

re: ColdFusion Form - Interdependent validation


Quote:

Originally Posted by itsmoorthy

Hi,

In the above case you can use the div tag, using div tag you can able to show & hide the controls according to your requirement.

Please try this out, you can definetely do that.

Regards,
Moorthy

That wouldn't be validation. That would show/hide with JavaScript, not validate the input. You would still need server-side validation.
Reply