winelover Posted September 8, 2010 Share Posted September 8, 2010 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 More sharing options...
ocpaul20 Posted September 8, 2010 Share Posted September 8, 2010 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 https://forums.phpfreaks.com/topic/212845-decimals-european-style/#findComment-1108657 Share on other sites More sharing options...
litebearer Posted September 8, 2010 Share Posted September 8, 2010 http://forums.mysql.com/read.php?21,362125,362670 Link to comment https://forums.phpfreaks.com/topic/212845-decimals-european-style/#findComment-1108659 Share on other sites More sharing options...
winelover Posted September 10, 2010 Author Share Posted September 10, 2010 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 https://forums.phpfreaks.com/topic/212845-decimals-european-style/#findComment-1109530 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.