BJ,
Okay, not familiar with cf_betterselect, but the below should still work for
you:
Change your cfform tag to this:
<cfform action="NewEmployeeEntry.cfm" name="newEmpInsertForm" method="POST"
onsubmit="return doSubmit();">
IN your <head> area, add the following:
<script>
function doSubmit() {
var oForm = document.newEmpInsertForm;
if(oForm.p_supervisor.selectedIndex == 0) {
alert('must select a supervisor');
return false;
}
if(oForm.p_location.selectedIndex == 0) {
alert('must select a location');
return false;
}
return true;
}
</script>
Change your <cfselect> to:
<select name="p_Location" class="boxes" required="yes" message="select
location">
<option></option>
<cfoutput query="EmpLocationsList">
<option value="#emp_locat#">#emp_locat#</option>
</cfoutput>
</select>
Modify the alerts to say whatever you want to say when wrong information is
entered.
Dave
-----Original Message-----
From: BJ McShane [mailto:[EMAIL PROTECTED]
Sent: Friday, August 22, 2008 4:54 PM
To: CF-Talk
Subject: Re: cflayout weird problem
Dave,
I am using cfform and some of the validation on tags with it. The two
places I don't is a custom tag I'm using cf_betterselect and the regular
select. the betterselect allows the user to type and narrow down the list.
the select tag I want the user to select a location and not have it default
to one so I put in an empty <option> tag. With this the validation will not
work when I set the cfselect tag to required.
Here's my code:
<cfform action="NewEmployeeEntry.cfm"
name="newEmpInsertForm" method="POST">
<cflayout type="tab" style="width:900;">
<cflayoutarea title="Employee Info"
style="background-color:##FFFFCC">
<table id="formTable">
<tr>
<td colspan="4" align="right">
<input type="submit"
name="insertHRpartButton" value="Update">
</td>
</tr>
<tr><td colspan="4"><hr width="80%"
align="center"></td></tr>
<tr>
<th>Name:</th>
<td>
<cfinput type="text"
name="p_employeeName" class="boxes" size="50" maxlength="70" required="yes"
message="Please enter the new employee's name" onChange="spacesCk(this);">
</td>
<th>Employee No.:</th>
<td>
<cfinput type="text" name="p_employeeNo"
class="boxes" size="4" maxlength="4" required="yes" message="Please enter
the employee's number" validate="integer" onChange="spacesCk(this);">
</td>
</tr>
<tr>
<th>Title:</th>
<td colspan="3">
<cfinput type="text"
name="p_employeeTitle" class="boxes" size="80" maxlength="100"
required="yes" message="Please enter the new employee's title"
onChange="spacesCk(this);">
</td>
</tr>
<tr>
<th>RCN:</th>
<td>
<cfinvoke
component="/hr/hr_CFCs/HR_employee" method="HREmployeeRCNInfo"
returnvariable="rcnlist">
<select name="p_employeeRCN"
class="boxes">
<option value=""></option>
<cfoutput query="rcnlist">
<option
value=#emp_rcn#>#emp_rcn# - #mid(emp_rcn_name,9,35)#</option>
</cfoutput>
</select>
</td>
<th>Time Reporting Group:</th>
<td>
<cfinput type="text"
name="p_employeeRptRCN" class="boxes" size="6" maxlength="6" required="no"
message="Please enter the new employee's Time Reporting Group"
onChange="spacesCk(this);">
</td>
</tr>
<tr>
<th>Supervisor:</th>
<td>
<cf_betterselect name="p_supervisor"
formname="newEmpInsertForm" class="boxes">
<option></option>
<cfoutput query="EmpInfoQuery">
<option
value="#emp_no#,#emp_last_name#,#emp_nick_name#">#emp_last_name#,
#emp_nick_name#</option>
</cfoutput>
</cf_betterselect>
</td>
<th>Start Date:</th>
<td>
<cfinput type="text" name="p_startDate"
class="boxes" size="10" maxlength="10" required="yes" validate="date"
message="Please enter the new employee's start date"
onChange="spacesCk(this);">
</td>
</tr>
<tr>
<th>Location:</th>
<td>
<cfselect name="p_Location"
class="boxes" required="yes" message="select location">
<cfoutput query="EmpLocationsList">
<option
value="#emp_locat#">#emp_locat#</option>
</cfoutput>
</cfselect>
</td>
</tr>
<!---tr>
<th>Functional Area:</th>
<td colspan="3">
<cfinput type="text"
name="p_functionalArea" class="boxes" size="80" maxlength="100"
onChange="spacesCk(this);">
</td>
</tr --->
<tr><td colspan="4"><hr width="80%"
align="center"></td></tr>
<tr>
<th>FERC/Walled Employee:</th>
<td>
<input type="checkbox" name="p_ferc">
</td>
<th>Transmission Apprentice:</th>
<td>
<input type="checkbox"
name="p_apprentice">
</td>
</tr>
<tr>
<th>Bargaining:</th>
<td>
<input type="radio" name="p_bargain"
value="B">
or
<strong>Non-Bargaining:</strong><input type="radio" name="p_bargain"
value="N" checked>
</td>
<th>Need Office:
<input type="radio" name="p_officeType"
value="O">
</th>
<td>
or <strong>Cubicle:</strong><input
type="radio" name="p_officeTYpe" value="C" checked>
or <strong>N/A:</strong><input
type="radio" name="p_officeTYpe" value="N">
</td>
</tr>
<tr>
<th>Laptop needed:</th>
<td>
<input type="checkbox" name="p_laptop">
</td>
<th>Desktop needed:</th>
<td>
<input type="checkbox" name="p_desktop">
</td>
</tr>
<tr>
<th>Cell phone needed:</th>
<td>
<input type="checkbox" name="p_cell">
</td>
<th>Broadband Card needed:</th>
<td>
<input type="checkbox" name="p_aircard">
</td>
</tr>
<tr>
<th>VPN needed:</th>
<td>
<input type="checkbox" name="p_VPN">
</td>
<th>Desk Phone:</th>
<td>
<strong>Digital</strong> <input
type="radio" name="p_phoneType" value="D">
or <strong>Analog</strong><input
type="radio" name="p_phoneType" value="A" checked>
</td>
</tr>
<tr><td colspan="4"><hr width="80%"
align="center"></td></tr>
<tr>
<th>
Additional Software:<br>
<span class="redText">(above
Standard)</span>
</th>
<td colspan="3">
<cftextarea name="p_additionalSoftware"
required="no" class="boxes" cols="60" rows="3"></cftextarea>
<br><span
class="redText"><strong>Standard Software Installed:</strong> Microsoft
Office, Internet Explorer, Outlook email, Adobe Acrobat Reader, Oracle,
Passport</span>
</td>
</tr>
<tr>
<th>
User Share Access:
</th>
<td colspan="3">
<cftextarea name="p_userShare"
required="no" class="boxes" cols="60" rows="3"></cftextarea>
</td>
</tr>
<tr>
<th>
Security Profile:
</th>
<td colspan="3">
<cftextarea name="p_security"
required="no" class="boxes" cols="60" rows="3"></cftextarea>
</td>
</tr>
<tr><td colspan="4"><hr width="80%"
align="center"></td></tr>
<tr>
<td colspan="4" align="right">
<input type="submit"
name="insertHRpartButton" value="Update">
</td>
</tr>
</table>
</cflayoutarea>
</cflayout>
</cfform>
>BJ,
>
>Post your form code (or a snippet) and what fields you're trying to
validate
>and what you want validated and we can help.
>
>Also, check out the CF docs for CFFORM as it has a lot of built-in
>javascript validation that you can utilize through CF tags like CFINPUT and
>so on.
>
>Dave
>
>Dave, thanks for the reply. I did run it in firefox and the data doesn't
>get wiped out in that browser. So you are right it looks like it is a
>browser issue. I've never validated with just javascript, I'll have to
look
>around for examples.
>
>thanks
>
>bj
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to
date
Get the Free Trial
http://ad.doubleclick.net/clk;203748912;27390454;j
Archive:
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:311447
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4