Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect separators #143

Closed
adamroof opened this issue May 14, 2015 · 14 comments
Closed

Incorrect separators #143

adamroof opened this issue May 14, 2015 · 14 comments

Comments

@adamroof
Copy link

Sql2008 datatype money: 12875.19
Expected results: 12,875.19

Options: none
Initializer: $(".jqNumeric").autoNumeric('init');

Error:
The value (12.875.19) being 'set' is not numeric and has caused a error to be thrown

No error for values without a thousands separator. Looks like it is trying to use non US currency defaults, but I've confirmed the defaults should be comma for thousands and decimal for cents. I am not displaying any currency symbols.

Source of error. I don't want to allow locale decimal to be a comma
/** allows locale decimal separator to be a comma */
if ((testValue === $this.attr('value') || testValue === $this.text()) && settings.runOnce === false) {
value = value.replace(',', '.');
}
if (!$.isNumeric(+value)) {
$.error("The value (" + value + ") being 'set' is not numeric and has caused a error to be thrown");
}

@BobKnothe
Copy link
Member

Adam,

autoNumeric is designed to take the first period '.' or comma ',' and
treat as the decimal character. So the following the following occurs:

12875.19 => 12875.19 OK
12875,19 => 12875.19 OK
12,875.19 => 12.875.19 fails

Is this occurring on page load, page re-load or with the 'set' method?
Also let me know the version you are using.

Can you duplicate this on jsFiddle?

Thanks,

Bob

On 5/14/2015 12:08 PM, Adam Roof wrote:

Sql2008 datatype money: 12875.19
Expected results: 12,875.19

Options: none
Initializer: $(".jqNumeric").autoNumeric('init');

Error:
The value (12.875.19) being 'set' is not numeric and has caused a
error to be thrown

No error for values without a thousands separator. Looks like it is
trying to use non US currency defaults, but I've confirmed the
defaults should be comma for thousands and decimal for cents. I am not
displaying any currency symbols.

Source of error. I don't want to allow locale decimal to be a comma
/** allows locale decimal separator to be a comma */
if ((testValue === $this.attr('value') || testValue === $this.text())
&& settings.runOnce === false) {
value = value.replace(',', '.');
}
if (!$.isNumeric(+value)) {
$.error("The value (" + value + ") being 'set' is not numeric and has
caused a error to be thrown");
}


Reply to this email directly or view it on GitHub
#143.

@adamroof
Copy link
Author

Thanks for your reply.
I expect 12.875.19 to fail, but that is not the data being presented.
It looks to be converting my correct value of 12,875.19 into 12.875.19

its occurring at this line: value = value.replace(',', '.');
its occurring on page load.

I am using the latest version as of yesterday. There was no error in v1.9.26 until I updated to the latest version of 1.9.36

@BobKnothe
Copy link
Member

Adam

Is this run under ASP.net?

Bob

On 5/15/2015 2:48 PM, Adam Roof wrote:

Thanks for your reply.
I expect 12.875.19 to fail, but that is not the data being presented.
It looks to be converting my correct value of 12,875.19 into 12.875.19

its occurring at this line: value = value.replace(',', '.');
its occurring on page load


Reply to this email directly or view it on GitHub
#143 (comment).

@adamroof
Copy link
Author

Yes

@adamroof
Copy link
Author

here is the fiddle http://jsfiddle.net/gxfLuxLL/

@BobKnothe
Copy link
Member

Adam

The value you have shows both a decimal point and a thousand separator
so autoNumeric which will can an error.

There are two way to approach

remove the comma

or

change the aForm option to falsewhich will prevent the value from being
formatted.

let me know if your issues is resolved.

Bob

On 5/15/2015 3:31 PM, Adam Roof wrote:

here is the fiddle http://jsfiddle.net/gxfLuxLL/


Reply to this email directly or view it on GitHub
#143 (comment).

@adamroof
Copy link
Author

Right, dollars and cents. $12,875.99
Some will enter the comma, some will not. All will enter a cents value.
The autoNumeric code should not attempt to replace my comma with a decimal point.
I would rather the code handle this appropriately.
Not sure why you are having the code replace the comma with a decimal, maybe if US currency, don't?

Also, I enter a value of 9,112,875.19 and get the error
The value (9.112,875.19) being 'set' is not numeric and has caused a error to be thrown

@BobKnothe
Copy link
Member

Adam,

autoNumeric is used throughout the world including locales where the
decimal point is a comma and this was my attempt to accommodate for
locale values on input. In addition there are even more thousand
separators used.

Regardless my documentation states the following:*

Default values*

The option "aForm" controls how default values are handled on page
ready. When "aForm: true" is true the defaults values of the the
supported elements that are controlled by autoNumeric are formatted on
page ready. When "aForm: false" is false the values are not formatted on
page ready, but input fields will be formatted when they have focus on
the first keypress event is fired.

So when aForm is set to true "aForm: true" the defaults value should be
un-formulated as follows:
or 9999.99. Have a
single decimal point and numeric characters only.

When aForm is set to false "aForm: False" the defaults values should be
pre-formatted as follows:
.

I am open to suggestions on modifications if they are not locale
specific. If you need a custom mod let me know and we can discuss the
details.

Best regards,

Bob

On 5/15/2015 4:28 PM, Adam Roof wrote:

Right, dollars and cents. $12,875.99
Some will enter the comma, some will not. All will enter a cents value.
The autoNumeric code should not attempt to replace my comma with a
decimal point.
I would rather the code handle this appropriately.
Not sure why you are having the code replace the comma with a decimal,
maybe if US currency, don't?


Reply to this email directly or view it on GitHub
#143 (comment).

@adamroof
Copy link
Author

ok, I see what you are saying on the aForm.

@adamroof
Copy link
Author

I am now getting the same error on the same line with percent fields. This was not an issue in 1.9.26 on another site that I am utilizing in the exact same approach. Is aForm going to be required on all future releases? This is a bug. Errors are not being completely handled and the reason for the errors are not attempted to be resolved internally. If I have to go unformatted I don't see the point in using the plugin. Don't get me wrong I LOVE what you have done with this. This is an issue across IE and Chrome, and I can recreate in jsFiddle so it is unrelated to being an "ASP.Net" issue.

New error on same line as previous error:
The value (0.00 %) being 'set' is not numeric and has caused a error to be thrown

Again, I understand that 0.00 % is NOT numeric due to the percentage sign. To resolve for now, I have added the following:

/** allows locale decimal separator to be a comma */
if ((testValue === $this.attr('value') || testValue === $this.text()) && settings.runOnce === false) {
    value = value.replace(',', '.');
}
//attempt to repair a percentage sign or dollar sign error
if (!$.isNumeric(+value)) { value = value.replace("$","").replace("%","").replace(" ",""); }
if (!$.isNumeric(+value)) {
    $.error("The value (" + value + ") being 'set' is not numeric and has caused a error to be thrown");
}

This was to resolve my current issues, I realize you have other variables to handle, just letting you know what I did to have it respond like the previous version.

Thanks for your time.

@BobKnothe
Copy link
Member

Adam,

Please create the fiddle in non- ASP.Net.

From what I saw this is a post back issue when the original value is
overwritten with the new value. If I missed something then the fiddle
will indicate what is wrong.

Regardless I will be posting a mod, hopefully tomorrow that will allow
the ASP.Net developer to check the original default.

Best regards,

Bob

On 5/21/2015 2:57 PM, Adam Roof wrote:

I am now getting the same error on the same line with percent fields.
This was not an issue in 1.9.26 on another site that I am utilizing in
the exact same approach. Is aForm going to be required on all future
releases? This is a bug. Errors are not being completely handled and
the reason for the errors are not attempted to be resolved internally.
If I have to go unformatted I don't see the point in using the plugin.
Don't get me wrong I LOVE what you have done with this. This is an
issue across IE and Chrome, and I can recreate in jsFiddle so it is
unrelated to being an "ASP.Net" issue.

New error on same line as previous error:
The value (0.00 %) being 'set' is not numeric and has caused a error
to be thrown

Again, I understand that 0.00 % is NOT numeric due to the percentage
sign. To resolve for now, I have added the following:

|/** allows locale decimal separator to be a comma */
if ((testValue === $this.attr('value') || testValue === $this.text()) && settings.runOnce === false) {
value = value.replace(',', '.');
}
//attempt to repair a percentage sign or dollar sign error
if (!$.isNumeric(+value)) { value = value.replace("$","").replace("%","").replace(" ",""); }
if (!$.isNumeric(+value)) {
$.error("The value (" + value + ") being 'set' is not numeric and has caused a error to be thrown");
}
|

This was to resolve my current issues, I realize you have other
variables to handle, just letting you know what I did to have it
respond like the previous version.

Thanks for your time.


Reply to this email directly or view it on GitHub
#143 (comment).

@BobKnothe
Copy link
Member

Adam,

I have a update that I would like to send to you for testing. It will require you to use html5 data attribute named data-an-default="" that has the same value as the value attribute like in the below example.

<asp:TextBox runat="server" ID="someID" value="1234.56" data-an-default="1234.56">

Please send me an email address at bob{@}decorplanit.com

Bob

@BobKnothe
Copy link
Member

sorry did not show the example

<asp:TextBox runat="server" ID="someID" value="1234.56" data-an-default="1234.56"/>

@TuyNguyen
Copy link

you only set aForm : false

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants