I have two inputs for users to enter, what should always be a nueric string. This string gets processed and some mathmatical cals done to them, then the results are returned to the same page via cf div and bind attribute. Everything works if only numbers are entered. I have assumed a cfqueryparam with a reg ex could be used, but not having much luck.
Here is the form inputs:
<cfform id="bulbForm">
<table align="center">
<tr>
<th>Lamp Voltage:</th>
<td><cfinput name="lampVoltage" type="text"></td>
</tr>
<tr>
<th>Socket Voltage:</th>
<td><cfinput name="socketVoltage" type="text" onBlur=""></td>
</tr>
<br />
</table>
</cfform>
<cfdiv bind="url:calcAction.cfm?lampVoltage={lampVoltage}&socketVoltage={socketVoltage}"
id="dynaDiv">
</div>
and the processing code:
<cfif url.lampVoltage NEQ "" AND url.socketVoltage NEQ "">
<cfset lampVolts = REReplaceNoCase(url.lampVoltage, '[^a-z0-9]', ', 'all')>
<cfset actualVolts = url.socketVoltage>
<!--- Set Constants For Calculations --->
<cfset lumens = 27500>
<cfset life = 500>
<cfset watts = 65>
<cfset colorTemp = 2870>
<!--- Perform Calculations --->
<cfset actualLumens = ((actualVolts/lampVolts)^3.4)*lumens>
<cfset lumenPercent = actualLumens/lumens*100>
<cfset hours = ((lampVolts/actualVolts)^13)*life>
<cfset hourPercent = hours/life*100>
<cfset actualWatts = ((actualVolts/lampVolts)^1.3)*watts>
<cfset wattPercent = actualWatts/watts*100>
<cfset temperature = ((actualVolts/lampVolts)^.42)*colorTemp>
<cfset tempReduction = temperature-colorTemp>
<h2>Photo Lamp Characteristics Calculator</h2>
<cfoutput>
<table>
<tr>
<th colspan="2" align="center"><h3>You have a lamp rated at #url.lampVoltage# volts with a socket carrying #url.socketVoltage# actual volts.</h3></th>
</tr>
<br />
<tr>
<th width="338" align="center"><strong>#round(lumenPercent)#%</strong></th>
<td width="470" align="left">Percent increase in Lumens/Candlepower/Light</td>
</tr>
<tr>
<th align="center"><strong>#round(hourPercent)#%</strong></th>
<td align="left">Percent increase in Rated Life</td>
</tr>
<br />
<tr>
<th align="center"><strong>#round(wattPercent)#%</strong></th>
<td align="left">Percent of Wattage used.</td>
</tr>
<br />
<tr>
<th align="center"><strong>#round(tempReduction)#°</strong></th>
<td align="left">Change in Color Temperature.</td>
</tr>
</table>
</cfoutput>
<cfelse>
<h3>Please enter Lamp and Socket Voltage above to calculate differences, then click in this gray box. Your results will display here automatically.</h3>
</cfif>
I copied the regex from a site, but somethings wrong. Any help is greatly appreciated.