Skip to main content
Participant
March 24, 2009
Question

Text field Form validation based on drop down option

  • March 24, 2009
  • 3 replies
  • 696 views
Hi

I need some help please!

I have a form that is collecting preferred mailing address information - (drop down to select home or work then text fields for the actual home and work address data).

If the person selects their preferred mailing address is home - I need those specific text fields to require entry. And vice versa with the work address fields if they select that work is their preferred address.

Does any one have any suggestions on doing this - either with cold fusion, javascript, cfform? Help please!!

Thank you!
This topic has been closed for replies.

3 replies

Inspiring
March 25, 2009
I do but I don't like spoon feeding people. What specific parts of my earlier posts did you have difficulty with?
Inspiring
March 25, 2009
The concept is like this:

<cfsavecontent variable="x">
cfinput tags etc
</cfsavecontent>

<cfsavecontent variable="y">
different cfinput tags etc
</cfsavecontent>

<script>
<cfoutput>
use toscript() to convert x and y to js variables
</cfoutput>
function to change the value of your div
</script>
<cfform>
<select call your function with the onChange attribute>
<cfoutput>
<div id="something">
#x#
</div>
etc
tda2Author
Participant
March 25, 2009
Hi, Thank you for the info - but that is a bit over my head. I realize i posted this question in the advanced section - but i am not that advanced of a coder. I was hoping someone might have an example of something already.
Inspiring
March 25, 2009
Use javascript. I learned by buying the book, Teach Yourself Javascript in 24 Hours.

Or, you could use a combination of cfsavecontent, cfform, and div, javascript. It will enable you to use the required attribute of cfinput.
tda2Author
Participant
March 25, 2009
HI Dan,
Thank you for the advice. Could you provide a little more detail?