HTML number field toLocalString not working

Multi tool use
Multi tool use












0















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










share|improve this question




















  • 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
















0















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










share|improve this question




















  • 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














0












0








0








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










share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 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














  • 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








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












3 Answers
3






active

oldest

votes


















2














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>





share|improve this answer































    1














    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




    1. not behave all the same in different browsers

    2. allows multiple .

    3. allows letter e


    I recommend use just text type instead, and check format by RegExp or other way






    share|improve this answer
























    • My existing project need to keep number format.

      – Shafikur Rahman
      Jan 1 at 5:00



















    0














    var formatter = new Intl.NumberFormat('de-DE', {
    minimumFractionDigits: 2
    });
    console.log("Output: "+formatter.format(sum));


    This working fine for me.






    share|improve this answer























      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
      });


      }
      });














      draft saved

      draft discarded


















      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









      2














      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>





      share|improve this answer




























        2














        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>





        share|improve this answer


























          2












          2








          2







          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>





          share|improve this answer













          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>






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jan 1 at 5:28









          ChetanChetan

          1014




          1014

























              1














              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




              1. not behave all the same in different browsers

              2. allows multiple .

              3. allows letter e


              I recommend use just text type instead, and check format by RegExp or other way






              share|improve this answer
























              • My existing project need to keep number format.

                – Shafikur Rahman
                Jan 1 at 5:00
















              1














              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




              1. not behave all the same in different browsers

              2. allows multiple .

              3. allows letter e


              I recommend use just text type instead, and check format by RegExp or other way






              share|improve this answer
























              • My existing project need to keep number format.

                – Shafikur Rahman
                Jan 1 at 5:00














              1












              1








              1







              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




              1. not behave all the same in different browsers

              2. allows multiple .

              3. allows letter e


              I recommend use just text type instead, and check format by RegExp or other way






              share|improve this answer













              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




              1. not behave all the same in different browsers

              2. allows multiple .

              3. allows letter e


              I recommend use just text type instead, and check format by RegExp or other way







              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered Jan 1 at 4:58









              Johnson LeeJohnson Lee

              192




              192













              • 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





              My existing project need to keep number format.

              – Shafikur Rahman
              Jan 1 at 5:00











              0














              var formatter = new Intl.NumberFormat('de-DE', {
              minimumFractionDigits: 2
              });
              console.log("Output: "+formatter.format(sum));


              This working fine for me.






              share|improve this answer




























                0














                var formatter = new Intl.NumberFormat('de-DE', {
                minimumFractionDigits: 2
                });
                console.log("Output: "+formatter.format(sum));


                This working fine for me.






                share|improve this answer


























                  0












                  0








                  0







                  var formatter = new Intl.NumberFormat('de-DE', {
                  minimumFractionDigits: 2
                  });
                  console.log("Output: "+formatter.format(sum));


                  This working fine for me.






                  share|improve this answer













                  var formatter = new Intl.NumberFormat('de-DE', {
                  minimumFractionDigits: 2
                  });
                  console.log("Output: "+formatter.format(sum));


                  This working fine for me.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Jan 9 at 7:18









                  Shafikur RahmanShafikur Rahman

                  1,90331125




                  1,90331125






























                      draft saved

                      draft discarded




















































                      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.




                      draft saved


                      draft discarded














                      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





















































                      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
                      RsbBrRmPlCRc90ssGlA1w yaIs,jE,gTUtbDaqta1t9GwyO92m42SsEFsFBHOCnveGbwxtAZ3UqC2 wI xC8bPg3cVB5CC60NR

                      Popular posts from this blog

                      Monofisismo

                      Angular Downloading a file using contenturl with Basic Authentication

                      Olmecas