HTML number field toLocalString not working
![Multi tool use Multi tool use](http://sgv.ssvwv.com/sg/ssvwvcomimagb.png)
Multi tool use
I have an HTML number field. This field value assigned throw following error
The specified value "101,5" is not a valid number. The value must match to the following regular expression: -?(d+|d+.d+|.d+)([eE][-+]?d+)?
I need a value to convert to french
format (de-DE).
My try is
var dispersePercentageInput = $('.disperse-percentage');
var percentage = 101.5
dispersePercentageInput.val(Number(percentage).toLocaleString('de-DE'));
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type="number" name="etude_disbursement_rate" value="100.00" class="disperse-percentage required" step="0.01" data-prefix="-" required="" id="id_etude_disbursement_rate" title="S'il vous plaît remplissez cet champ">
I expect value is 101,5
but it shows The specified value "101,5" is not a valid number.
My input field is
<input type="number" name="etude_disbursement_rate" value="100.00" class="disperse-percentage required" step="0.01" data-prefix="-" required="" id="id_etude_disbursement_rate" title="S'il vous plaît remplissez cet champ">
User input in en-US format
javascript jquery
|
show 3 more comments
I have an HTML number field. This field value assigned throw following error
The specified value "101,5" is not a valid number. The value must match to the following regular expression: -?(d+|d+.d+|.d+)([eE][-+]?d+)?
I need a value to convert to french
format (de-DE).
My try is
var dispersePercentageInput = $('.disperse-percentage');
var percentage = 101.5
dispersePercentageInput.val(Number(percentage).toLocaleString('de-DE'));
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type="number" name="etude_disbursement_rate" value="100.00" class="disperse-percentage required" step="0.01" data-prefix="-" required="" id="id_etude_disbursement_rate" title="S'il vous plaît remplissez cet champ">
I expect value is 101,5
but it shows The specified value "101,5" is not a valid number.
My input field is
<input type="number" name="etude_disbursement_rate" value="100.00" class="disperse-percentage required" step="0.01" data-prefix="-" required="" id="id_etude_disbursement_rate" title="S'il vous plaît remplissez cet champ">
User input in en-US format
javascript jquery
2
Working fine for me, can you reproduce in snippet?
– Just code
Jan 1 at 4:49
I am usingjQuery v1.11.2
version. Is this produce error?
– Shafikur Rahman
Jan 1 at 4:58
No, it has nothing to do with jquery version.
– Just code
Jan 1 at 4:59
What does your actual input HTML look like? Is it the same as what was added by Mamun?
– H77
Jan 1 at 5:01
I can see the desired value in the console. But it not shows in input field.
– Shafikur Rahman
Jan 1 at 5:03
|
show 3 more comments
I have an HTML number field. This field value assigned throw following error
The specified value "101,5" is not a valid number. The value must match to the following regular expression: -?(d+|d+.d+|.d+)([eE][-+]?d+)?
I need a value to convert to french
format (de-DE).
My try is
var dispersePercentageInput = $('.disperse-percentage');
var percentage = 101.5
dispersePercentageInput.val(Number(percentage).toLocaleString('de-DE'));
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type="number" name="etude_disbursement_rate" value="100.00" class="disperse-percentage required" step="0.01" data-prefix="-" required="" id="id_etude_disbursement_rate" title="S'il vous plaît remplissez cet champ">
I expect value is 101,5
but it shows The specified value "101,5" is not a valid number.
My input field is
<input type="number" name="etude_disbursement_rate" value="100.00" class="disperse-percentage required" step="0.01" data-prefix="-" required="" id="id_etude_disbursement_rate" title="S'il vous plaît remplissez cet champ">
User input in en-US format
javascript jquery
I have an HTML number field. This field value assigned throw following error
The specified value "101,5" is not a valid number. The value must match to the following regular expression: -?(d+|d+.d+|.d+)([eE][-+]?d+)?
I need a value to convert to french
format (de-DE).
My try is
var dispersePercentageInput = $('.disperse-percentage');
var percentage = 101.5
dispersePercentageInput.val(Number(percentage).toLocaleString('de-DE'));
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type="number" name="etude_disbursement_rate" value="100.00" class="disperse-percentage required" step="0.01" data-prefix="-" required="" id="id_etude_disbursement_rate" title="S'il vous plaît remplissez cet champ">
I expect value is 101,5
but it shows The specified value "101,5" is not a valid number.
My input field is
<input type="number" name="etude_disbursement_rate" value="100.00" class="disperse-percentage required" step="0.01" data-prefix="-" required="" id="id_etude_disbursement_rate" title="S'il vous plaît remplissez cet champ">
User input in en-US format
var dispersePercentageInput = $('.disperse-percentage');
var percentage = 101.5
dispersePercentageInput.val(Number(percentage).toLocaleString('de-DE'));
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type="number" name="etude_disbursement_rate" value="100.00" class="disperse-percentage required" step="0.01" data-prefix="-" required="" id="id_etude_disbursement_rate" title="S'il vous plaît remplissez cet champ">
var dispersePercentageInput = $('.disperse-percentage');
var percentage = 101.5
dispersePercentageInput.val(Number(percentage).toLocaleString('de-DE'));
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type="number" name="etude_disbursement_rate" value="100.00" class="disperse-percentage required" step="0.01" data-prefix="-" required="" id="id_etude_disbursement_rate" title="S'il vous plaît remplissez cet champ">
javascript jquery
javascript jquery
edited Jan 1 at 5:32
Shafikur Rahman
asked Jan 1 at 4:45
Shafikur RahmanShafikur Rahman
1,90331125
1,90331125
2
Working fine for me, can you reproduce in snippet?
– Just code
Jan 1 at 4:49
I am usingjQuery v1.11.2
version. Is this produce error?
– Shafikur Rahman
Jan 1 at 4:58
No, it has nothing to do with jquery version.
– Just code
Jan 1 at 4:59
What does your actual input HTML look like? Is it the same as what was added by Mamun?
– H77
Jan 1 at 5:01
I can see the desired value in the console. But it not shows in input field.
– Shafikur Rahman
Jan 1 at 5:03
|
show 3 more comments
2
Working fine for me, can you reproduce in snippet?
– Just code
Jan 1 at 4:49
I am usingjQuery v1.11.2
version. Is this produce error?
– Shafikur Rahman
Jan 1 at 4:58
No, it has nothing to do with jquery version.
– Just code
Jan 1 at 4:59
What does your actual input HTML look like? Is it the same as what was added by Mamun?
– H77
Jan 1 at 5:01
I can see the desired value in the console. But it not shows in input field.
– Shafikur Rahman
Jan 1 at 5:03
2
2
Working fine for me, can you reproduce in snippet?
– Just code
Jan 1 at 4:49
Working fine for me, can you reproduce in snippet?
– Just code
Jan 1 at 4:49
I am using
jQuery v1.11.2
version. Is this produce error?– Shafikur Rahman
Jan 1 at 4:58
I am using
jQuery v1.11.2
version. Is this produce error?– Shafikur Rahman
Jan 1 at 4:58
No, it has nothing to do with jquery version.
– Just code
Jan 1 at 4:59
No, it has nothing to do with jquery version.
– Just code
Jan 1 at 4:59
What does your actual input HTML look like? Is it the same as what was added by Mamun?
– H77
Jan 1 at 5:01
What does your actual input HTML look like? Is it the same as what was added by Mamun?
– H77
Jan 1 at 5:01
I can see the desired value in the console. But it not shows in input field.
– Shafikur Rahman
Jan 1 at 5:03
I can see the desired value in the console. But it not shows in input field.
– Shafikur Rahman
Jan 1 at 5:03
|
show 3 more comments
3 Answers
3
active
oldest
votes
Please use "autoNumeric.min.js"
<script src="~/Scripts/autoNumeric/autoNumeric.min.js" type="text/javascript"></script>
add input tag in HTML file :
<input type="text" class="form-control" id="numberint" data-a-dec="," data-a-sep="." data-a-sign="">
Script code :
<script type="text/text/javascript">
$(function() {
$('#numberint').autoNumeric('init');
});
</script>
add a comment |
yeah, of course. input:type=number
is not a good choice, it can just accept common format, but your format is very infrequent.
and number
type has some other defects, such as
- not behave all the same in different browsers
- allows multiple
.
- allows letter
e
I recommend use just text
type instead, and check format by RegExp or other way
My existing project need to keep number format.
– Shafikur Rahman
Jan 1 at 5:00
add a comment |
var formatter = new Intl.NumberFormat('de-DE', {
minimumFractionDigits: 2
});
console.log("Output: "+formatter.format(sum));
This working fine for me.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53993062%2fhtml-number-field-tolocalstring-not-working%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
Please use "autoNumeric.min.js"
<script src="~/Scripts/autoNumeric/autoNumeric.min.js" type="text/javascript"></script>
add input tag in HTML file :
<input type="text" class="form-control" id="numberint" data-a-dec="," data-a-sep="." data-a-sign="">
Script code :
<script type="text/text/javascript">
$(function() {
$('#numberint').autoNumeric('init');
});
</script>
add a comment |
Please use "autoNumeric.min.js"
<script src="~/Scripts/autoNumeric/autoNumeric.min.js" type="text/javascript"></script>
add input tag in HTML file :
<input type="text" class="form-control" id="numberint" data-a-dec="," data-a-sep="." data-a-sign="">
Script code :
<script type="text/text/javascript">
$(function() {
$('#numberint').autoNumeric('init');
});
</script>
add a comment |
Please use "autoNumeric.min.js"
<script src="~/Scripts/autoNumeric/autoNumeric.min.js" type="text/javascript"></script>
add input tag in HTML file :
<input type="text" class="form-control" id="numberint" data-a-dec="," data-a-sep="." data-a-sign="">
Script code :
<script type="text/text/javascript">
$(function() {
$('#numberint').autoNumeric('init');
});
</script>
Please use "autoNumeric.min.js"
<script src="~/Scripts/autoNumeric/autoNumeric.min.js" type="text/javascript"></script>
add input tag in HTML file :
<input type="text" class="form-control" id="numberint" data-a-dec="," data-a-sep="." data-a-sign="">
Script code :
<script type="text/text/javascript">
$(function() {
$('#numberint').autoNumeric('init');
});
</script>
answered Jan 1 at 5:28
ChetanChetan
1014
1014
add a comment |
add a comment |
yeah, of course. input:type=number
is not a good choice, it can just accept common format, but your format is very infrequent.
and number
type has some other defects, such as
- not behave all the same in different browsers
- allows multiple
.
- allows letter
e
I recommend use just text
type instead, and check format by RegExp or other way
My existing project need to keep number format.
– Shafikur Rahman
Jan 1 at 5:00
add a comment |
yeah, of course. input:type=number
is not a good choice, it can just accept common format, but your format is very infrequent.
and number
type has some other defects, such as
- not behave all the same in different browsers
- allows multiple
.
- allows letter
e
I recommend use just text
type instead, and check format by RegExp or other way
My existing project need to keep number format.
– Shafikur Rahman
Jan 1 at 5:00
add a comment |
yeah, of course. input:type=number
is not a good choice, it can just accept common format, but your format is very infrequent.
and number
type has some other defects, such as
- not behave all the same in different browsers
- allows multiple
.
- allows letter
e
I recommend use just text
type instead, and check format by RegExp or other way
yeah, of course. input:type=number
is not a good choice, it can just accept common format, but your format is very infrequent.
and number
type has some other defects, such as
- not behave all the same in different browsers
- allows multiple
.
- allows letter
e
I recommend use just text
type instead, and check format by RegExp or other way
answered Jan 1 at 4:58
![](https://lh4.googleusercontent.com/-D-mAGc_1Cy0/AAAAAAAAAAI/AAAAAAAAAAs/FchiD7809Wo/photo.jpg?sz=32)
![](https://lh4.googleusercontent.com/-D-mAGc_1Cy0/AAAAAAAAAAI/AAAAAAAAAAs/FchiD7809Wo/photo.jpg?sz=32)
Johnson LeeJohnson Lee
192
192
My existing project need to keep number format.
– Shafikur Rahman
Jan 1 at 5:00
add a comment |
My existing project need to keep number format.
– Shafikur Rahman
Jan 1 at 5:00
My existing project need to keep number format.
– Shafikur Rahman
Jan 1 at 5:00
My existing project need to keep number format.
– Shafikur Rahman
Jan 1 at 5:00
add a comment |
var formatter = new Intl.NumberFormat('de-DE', {
minimumFractionDigits: 2
});
console.log("Output: "+formatter.format(sum));
This working fine for me.
add a comment |
var formatter = new Intl.NumberFormat('de-DE', {
minimumFractionDigits: 2
});
console.log("Output: "+formatter.format(sum));
This working fine for me.
add a comment |
var formatter = new Intl.NumberFormat('de-DE', {
minimumFractionDigits: 2
});
console.log("Output: "+formatter.format(sum));
This working fine for me.
var formatter = new Intl.NumberFormat('de-DE', {
minimumFractionDigits: 2
});
console.log("Output: "+formatter.format(sum));
This working fine for me.
answered Jan 9 at 7:18
Shafikur RahmanShafikur Rahman
1,90331125
1,90331125
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53993062%2fhtml-number-field-tolocalstring-not-working%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
LC EZiiREDVi
2
Working fine for me, can you reproduce in snippet?
– Just code
Jan 1 at 4:49
I am using
jQuery v1.11.2
version. Is this produce error?– Shafikur Rahman
Jan 1 at 4:58
No, it has nothing to do with jquery version.
– Just code
Jan 1 at 4:59
What does your actual input HTML look like? Is it the same as what was added by Mamun?
– H77
Jan 1 at 5:01
I can see the desired value in the console. But it not shows in input field.
– Shafikur Rahman
Jan 1 at 5:03