If you are only allowing full dollars, you could use this on your input
box...

onkeypress="if ((event.keyCode < 48) || (event.keyCode > 57))
event.returnValue = false;"

Or this if you want to allow .'s

onkeypress="if (((event.keyCode < 48) || (event.keyCode > 57)) &!
(event.keyCode==46)) event.returnValue = false;"

A simple isnumeric() test on the submitted field should be enough to
validate it then.

-----Original Message-----
From: Jim Campbell [mailto:[EMAIL PROTECTED] 
Sent: 13 August 2003 15:43
To: CF-Talk
Subject: Re: Inserting Currency Values...I bet this is a silly
question...


If you're only allowing dollar amounts (no decimals), it would probably 
be a lot easier to simply request that the user only enter numbers, no 
punctuation or other things.  This makes checking the value very easy 
and fast in both Javascript and CF before inserting. 

- Jim

Jeff wrote:

>Okay, in the database the price is stored as an int (SQL Server 2k) and

>formatted on output to currency. On the form, the field is a text field

>passing the value that's typed in.
>
>Problem: When the user types "$250,000" into the price field to insert 
>a record, the error on insert indicates that "there are fewer columns 
>in the INSERT statement than values specified in the VALUES clause". In

>other words, the comma in the price is throwing it off.
>
>I'd like to allow the user to type in their own way of expressing a 
>price (one user might type "250000" one might type "250,000" and one 
>might type "$250,000"...I'd like all to be "correct" if possible) and 
>having it accept it and store it as an int like I'm guessing it should 
>be. It is after all, a positive, somewhat large and varying, number.
>
>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq

Get the mailserver that powers this list at 
http://www.coolfusion.com

                                Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
                                

Reply via email to