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
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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.