NetTalk Central
NetTalk Web Server => Web Server - Ask For Help => Topic started by: rainerwallenius on December 11, 2014, 04:51:04 AM
-
Hi all
Sorry if this topic is already covered but I did not find it so here comes the question.
What is the best way to handle decimal comma or period.
Best would be if the program could accept both a comma or period as decimal character, ie 123.23 or 123,23. Now we get 123.23 => 123.23 and 123,23=> 12323 which is not good. The finnish/swedish keyboard layout generates a comma from numpad and accountants are used to enter numeroc values from numpad.
My application consists of tens or hundred of forms and several hundred fields so manual change is not a very welcome suggestion.
Any help is appreciated (even an RTFM-answer if it pinpoints to the right place ;)
:: rainer
-
Hi Rainer,
are you using the STRING or NUMBER form field type?
Cheers
Bruce
-
Hi Bruce
Only STRING
:: rainer
-
Any ideas anybody?
What is the best way to handle decimal comma or period.
Best would be if the program could accept both a comma or period as decimal character, ie 123.23 or 123,23. Now we get 123.23 => 123.23 and 123,23=> 12323 which is not good. The finnish/swedish keyboard layout generates a comma from numpad and accountants are used to enter numeroc values from numpad.
where in the templates can I tweak this?
TIA
:: rainer
-
I made two changes in netweb.tpw (and a function)
Inside validation I use a function that returns a string that replaces comma with dot (if numeric values)
This does the magic
The downside is that I have to make sme changes every time Bruce updates Nettalk so if there is
a more generic way to do this, it would be great to hear about it.
:: rainer
############################################################################
#End
#Embed(%CustomValidate,'Validate New Value'),%FormID,TREE('Routines|'&%TabHeading&' Tab|'&%FormID&' Field|'&%FormID&' Field|Validate::'&%FormId&' Routine|4 Middle')
If p_web.Ajax = 1 and p_web.ifExistsValue('NewValue')
#IF((%FormFieldType<>'Browse') and (%FormField <>''))
#IF(%FieldType='MEMO' or %FieldType='BLOB')
bloblen = len(p_web.GetValue('NewValue'))
#IF(%FieldType='MEMO')
If BlobLen <= Len(%FormField)
%FormField = p_web.GetValue('NewValue')
End
#ELSE
%FormField[1 : bloblen] = p_web.GetValue('NewValue')
#ENDIF
#ElsIf(%FormFieldType='Color')
%FormField = p_web.dFormat(NoComma(p_web.GetValue('NewValue')),'%FromFieldColorAs') ! <================
#ELSE
%FormField = NoComma(p_web.GetValue('NewValue')) ! <==============
#ENDIF
#ENDIF
#case(%FormFieldType)
#of('Slider')
###############################################################################
-
Hi Rainer,
I have added a smart number deformatter to build 8.34.
Note that his will require a StringTheory update (to 2.14 or later).
This will try and be "clever" about the number being entered. Specifically if the user enters a single , or . character then it will look at the picture to determine if decimal places are expected. If they are expected then it will be assumed that that is the decimal point.
cheers
Bruce
-
Hi Bruce
Sounds great!
Have a very succesful 2015!
:: rainer