<script language="javascript" type="text/javascript">
function validateForm()
{
        var msg = '';
        var isValid = true;

        if(document.forms[0].selectAdmin.value == 'xox')
        {
                if (document.forms[0].adminName.value.length == 0)
                {
                        msg = 'Name is required\n';
                        isValid = false;
                }
                if (document.forms[0].adminEmail.value.length == 0)
                {
                        msg = msg + 'Email is required';
                        isValid = false;
                }
        }
        
        if (!isValid) { alert(msg); }
        return isValid;
        
}
</script>

<form action="mypage.cfm" method="post">

<select name="selectAdmin">
  <option value="xox">Other - Enter Information Below!</option>
  <option value="1">Joe Blow</option>
</select>
<br />
Name: <input type="text" name="adminName" /><br />
Email: <input type="text" name="adminEmail" />


<br /><br />
<input type="submit" onclick="return validateForm();" />
</form>

-----Original Message-----
From: Les Mizzell [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, October 10, 2006 12:27 PM
To: CF-Talk
Subject: Tricky Form validation Question (for me at least)

This is probably going to take more javascript than I know how to do, 
since I suck at javascript...

First page of a multi-part form has a drop-down of admin namex to pick from.


<select name="selectAdmin">
  <option value="xox">Other - Enter Information Below!</option>
    <cfloop query="AIData">
      <option value="#MyData.AdminEmail#">#MyData.AdminNam1#</option>
    </cfloop>
</select>

If you ain't in the list, then you should fill in "adminNAME" and 
"adminEMAIL" text fields below that.


I've not quit figured out how to validate this on one page. If "Other" 
is picked in the select, then I need validation for "adminNAME" and 
"adminEMAIL" to happen before the form can be submitted. If "Other" 
ain't picked, then ignore them...

I can check for this on the NEXT page of the form and force them to fill 
in the blanks there, but I want it to take place all on the first page.





~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four 
times a year.
http://www.fusionauthority.com/quarterly

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:256137
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to