I got it! (I think this is the first time I've ever used
a Regex...sad, huh?)
I couldn't use the UDF M!ke mentioned, but I did
take the Regex from the code and used as follows:
(This code allows an entry of a number in any format,
such as, $1,000, or 1,000 to entered and not cause
an error on either the processing or display side...)
4.5.2 lives! :o)
Error Trapping Code:
<CFIF Not Len(Trim(Form.Premium))>
<CFSET Form_Errors.Premium = "Please enter the premium.">
<CFELSEIF Len(Trim(Form.Premium)) and Not
IsNumeric(REReplace(Form.Premium, "[^0-9\.]",'','All'))>
<CFSET Form_Errors.Premium = "Please enter a valid number for the
premium.">
</CFIF>
Display Code for the FormField:
<CFIF IsDefined("Form.Issuing_Company") and Not
IsDefined("Form_Errors.Premium")>
<INPUT Name="Premium" Type="Text"
Value="<CFOUTPUT>#DollarFormat(LSParseCurrency(Form.Premium))#</CFOUTPUT>"
Size="30" Class="TextInput01">
<CFELSEIF IsDefined("Form.Issuing_Company") and
IsDefined("Form_Errors.Premium")>
<INPUT Name="Premium" Type="Text"
Value="<CFOUTPUT>#Form.Premium#</CFOUTPUT>" Size="30" Class="TextInput01">
<CFELSEIF Not IsDefined("Form.Issuing_Company")>
<INPUT Name="Premium" Type="Text" Value="" Size="30"
Class="TextInput01">
</CFIF>
> -----Original Message-----
> From: Rick Faircloth [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, March 07, 2006 10:56 AM
> To: CF-Talk
> Subject: RE: Ok, I give...how can I do this...
>
>
> So, basically, what you're saying (besides "upgrade!" :o),
> is that it can't be done with any combination of CFIF statements...right?
>
> I'm trying to figure out if I'm just continuing to beat a dead horse...
>
> Rick
>
> > -----Original Message-----
> > From: S. Isaac Dealey [mailto:[EMAIL PROTECTED]
> > Sent: Tuesday, March 07, 2006 10:08 AM
> > To: CF-Talk
> > Subject: RE: Ok, I give...how can I do this...
> >
> >
> > > CFIF Len(Trim(Form.Dollar_Amount)) and Not
> > > IsNumeric(LSParseNumber(Form.Dollar_Amount))
> >
> > > - Now why didn't this work? Oh, now I remember...a junk
> > > entry like, asdflkj, can't
> > > be parsed by LSParseNumber and throws a CF error...
> >
> > Oh yeah, sorry... I forgot that the behavior of LSParseNumber() is ...
> > horrific...
> >
> > It would be _MUCH_ better for it to return an empty string than to
> > throw an error, but I digress...
> >
> > <cftry>
> > <cfif len(trim(form.dollar_amount)) and
> > not isNumeric(LSParseNumber(trim(form.dollar_amount)))>
> > <cfthrow type="validation" message="not a number">
> > </cfif>
> > <cfcatch>
> > ... do some stuff with the bad number information ...
> > </cfcatch>
> > </cftry>
> >
> > Here's a good reason to upgrade. :) If you were using a more recent
> > version of CF (specifically MX or later) you could put this try-catch
> > block into a custom function so that you wouldn't have to repeat it
> > for each field you wanted to validate.
> >
> > Note that I trim the form value before executing LSParseNumber() -- I
> > suspect that white space before or after the number may also cause an
> > error on an otherwise valid number, so it's probably better to just
> > trim it to be sure.
> >
> >
> > > CFIF Len(Trim(Form.Dollar_Amount)) and Not
> > > IsNumeric(LSParseNumber(Val(Form.Dollar_Amount)))
> >
> > > - Worked for entries like 1,000 but didn't work with junk
> > > entries, like
> > > sldifjo,
> > > because I think Val created a value of 0 for the string
> >
> > Yep, it does. Val() in general is probably most useful for performing
> > math with query data when the column might contain a null.
> >
> >
> > s. isaac dealey 434.293.6201
> > new epoch : isn't it time for a change?
> >
> > add features without fixtures with
> > the onTap open source framework
> >
> > http://www.fusiontap.com
> > http://coldfusion.sys-con.com/author/4806Dealey.htm
> >
> >
> >
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:234453
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54