Prevent formatting of numbers when displayed in a textbox
I have a feature editing workflow that reads attributes from a feature into a form. When an integer attribute from the feature is displayed in a form textbox, the number is formatted with space as thousands separator. So a value of 3456 becomes 3 456 in the form. When the attributes are saved back to the database the workflow crashes because it can't translate a text of "3 456" back into an integer. Is this formatting of numbers controlled by general settings in Essentials or GVH? Is there a way to prevent this formatting from happening. I guess I could trim away the space from the text before running Update Features, but I don't want numbers in text to be formatted with thousands separator either.
-
Hello Jostein,
When you enter a value into a Text Box element, the element assumes that the value entered will correspond to text. You can use the Parse Number activity to access the input value as a number after the form is submitted.
I believe the formatting of the input value is controlled based on your region settings within the browser. How are you populating the Text Box with this value?
Thanks, Stefan
0 -
Ok, but I don't want the number to be formatted with a thousands separator when displayed as text. Is that behavior configurable? Or do I have to use a Number form element instead of a Text Box?
0 -
As far as I can see, Parse Number is not able to parse "3 456" into the number 3456?
0 -
Hi Jostein,
I'm interested in knowing what your process is for populating the Text Box, and what your system and browser language settings are so that I can try to reproduce this issue.
0 -
Client side or server side?
0 -
I'm mostly interesting in client-side, but the server-side info would be useful as well.
0 -
Client side is Norwegian.
I am sending =$form1.state.textBox1.value (containing "3 456") into a Parse Number with ID number1, and use =$number1.result as the attribute value in Set Feature Attribute. What I see when writing the feature.toJson() to the log is that the value is NaN.
0 -
I've been able to reproduce the behaviour you mentioned and its because of the client Language settings and how we display the number inside of an element that expects text. Using a Number form element prevents this issue, since outside of the form you'd access the actual value rather than the displayed value: =$form1.state.number1.value.numeric
0 -
Thanks, I'll try that, but it is some work involved in changing from textbox to numeric. But with a text box, how do I avoid the displayed value being formatted with a thousands separator? We don't usually do that in Norwegian
0 -
It shouldn't appear within the Number. My example used a ',' as a thousands separator but in the form element it appears without it.
0 -
So conclusion is: Use Number for numbers, not TextBox?
0 -
When you are expecting a Number as input, then that holds true. A Text Box is intended to be used for String inputs. You can use the Text Box, but you might need to do some input/output sanitization of the values.
0
Du måste logga in om du vill lämna en kommentar.
Kommentarer
12 kommentarer