Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form List with Numbers?

Status
Not open for further replies.

DaveL

Programmer
Jun 8, 2000
40
US
I have four products on a form where the user will enter the prices for products. If they input a comma with the price (when the price > 999.99), the resulting form list sees the extra comma as a delimeter and my results are messed up:

My list entries look like the following:

PRICE equals 210.00, 500.00, 1,500.00, 300.00

When I process the list, my results are as follows:

210.00, 500.00, 1, 500.00

Can anybody give me ideas on the best way to handle this?
 
The problem here is you are capturing the prices in one form field instead of four. Even if you validate the form client-side with JavaScript, you'll still have the comma problem, because you will in effect be checking a list generated by JavaScript for a comma!

If you use 4 separately-named form fields, you can then validate client-side and server-side by making sure there are no commas present in those fields, OR you could just accept the commas in the input and use the Replace() function to replace them with an empty value.

-Tek
 
Tek,

Thanks for the tip! It led me in the right direction and I figured it out.

DaveL
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top