Jump to content

decimals (european style)


winelover

Recommended Posts

Hi,

 

I have a page on which decimal values are entered.

The problem is however that sql does not recognize the comma (the european decimal separator) as the decimal separator.

How can I change the input to something that sql can accept?

And what if someone enters a number in English format (a dot instead of a comma)? Or uses thousands-separators?

Has anyone have experience with this?

 

Greetz,

Winelover

Link to comment
https://forums.phpfreaks.com/topic/212845-decimals-european-style/
Share on other sites

Can't you accept european decimals but store the values in normal dot decimals and then format the output to show in european decimals again. That way, it really does not matter how they enter their decimal.

 

Of course, you will have to do validation and reformatting of the input they type in. This will either have to be done client side of server side but if I was you, I would probably check it server side again before I wrote it away to the database anyway.

Thanks for the replies.

The formatting is not the problem. The problem is more the input.

I wanted to give the possibility to enter the amount with either a dot or a comma. And also check if one entered thousands separators or not.

Now I added a little JavaScript to accept only one optional comma and numbers and the replace the comma with a dot before storing in the database. Problem solved.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.