Personally I'd still make it money. You never know when goofy stuff
in the future might happen to make decimal places necessary, like if
they apply some weird discount, etc. Just thinking out loud here,
and you're right that a property probably wouldn't ever have
decimals, but I'd use money as the datatype anyway. Better to have
it and not use it than have to change it in the future, and it's
simple enough to use CF for number formatting so it doesn't show the
decimals.
Matt
On Jun 18, 2005, at 4:06 PM, Ryan Everhart wrote:
Thanks for the reply Matt!
If you were designing an application that contained property listings,
woud you make the field in the database a money or numeric value? It
seems to me it might be better suited as a numeric field since you
would very rarely see a home go for $275,000.99. It seems by defaul
that money carries the two decimal places where as you can tell
numeric not to.
On 6/18/05, Matthew Woodward <[EMAIL PROTECTED]> wrote:
I believe the correct answer here is "both." :-) You absolutely
shouldn't rely only on javascript to check the data that's getting
put into your database. This can be a good way to catch initial
problems (a simple regular expression or use of a validation library
like qForms can catch a lot of stuff IF the user has javascript
enabled), but you must always also validate the data on the server-
side before allowing anything into your database. If you check the
data on the server and can't automatically fix any issues as you
outline or the data fails a regular expression or some other
validation CF can do (the new IsValid() function in CFMX 7 comes in
handy here), then you'd just have to route the user back to the form
and inform them that they need to try again.
Matt
On Jun 18, 2005, at 2:23 PM, Ryan Everhart wrote:
Hey guys,
I just need some feed back on how to treat prices as far as forms
and
adding them to the database.
Basically, how do you do it? Right now I have a field in my
database
with the data type of MONEY. This field will hold the price of a
property. It seems that the db only like numeric values being added
into that field, which makes sense. So how do you guys validate and
make sure your users put in only numeric values and that they don't
add any $ or , into the form fields? Do you do JavaScript to check
before the form is submitted, or do you just use a ColdFusion
Replace
function and remove all invalid characters before they are submitted
to the query?
Thanks,
Ryan
----------------------------------------------------------
To post, send email to [email protected]
To unsubscribe:
http://www.dfwcfug.org/form_MemberUnsubscribe.cfm
To subscribe:
http://www.dfwcfug.org/form_MemberRegistration.cfm
--
Matthew Woodward
[EMAIL PROTECTED]
----------------------------------------------------------
To post, send email to [email protected]
To unsubscribe:
http://www.dfwcfug.org/form_MemberUnsubscribe.cfm
To subscribe:
http://www.dfwcfug.org/form_MemberRegistration.cfm
----------------------------------------------------------
To post, send email to [email protected]
To unsubscribe:
http://www.dfwcfug.org/form_MemberUnsubscribe.cfm
To subscribe:
http://www.dfwcfug.org/form_MemberRegistration.cfm
--
Matthew Woodward
[EMAIL PROTECTED]
----------------------------------------------------------
To post, send email to [email protected]
To unsubscribe:
http://www.dfwcfug.org/form_MemberUnsubscribe.cfm
To subscribe:
http://www.dfwcfug.org/form_MemberRegistration.cfm