numeric textbox gives problem while trying to submit

6 posts, 0 answers
  1. Goran
    Goran avatar
    3 posts
    Member since:
    Oct 2012

    Posted 09 Oct 2012 Link to this post

    I am trying to submit a form that contains localized data and numeric textboxes with decimal numbers.

    The culture I use is hr-HR and decimal data numbers look like 123,45. the problem is that whenever the decimals are present, the form will not submit. I think it might be the validation because of the (,)  instead of the dot, If I leave zeroes in decimal places, the form submits nicely.

    How do I get the form to accept localized decimal numbers?

    ------------

    I've realized that the NumericTextbox doesnt see comma (which are created on GET) as the decimal separator. And due to change culture I cannot use dots. So Im cornered.

    Is this a bug or am I missing something?

     

  2. kvn
    kvn avatar
    3 posts
    Member since:
    Dec 2009

    Posted 30 Sep 2013 Link to this post

    Hi Goran,
    I face the same problem. Did You ever find a solution?
    /Kristian
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Alexander Popov
    Admin
    Alexander Popov avatar
    1416 posts

    Posted 02 Oct 2013 Link to this post

    Hello Kristian,

    This happens because when a form is submitted the browser is sending the input elements values. In this scenario however, there is a difference between the input value and the actual Widget value. I would recommend you to attach a handler to the form's submit event and assign proper values to the numeric input elements. For convenience I created this small example demonstrating such behavior.
     

    Regards,
    Alexander Popov
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  5. kvn
    kvn avatar
    3 posts
    Member since:
    Dec 2009

    Posted 03 Oct 2013 Link to this post

    Hello Alexander,

    Thank you for your answer and example.
    But  I believe that the problem I am facing might have a different explanation.

    This is my scenario: 
    On a HTML page I have a form with two numeric txtboxes using format N2, validation enabled and the culture set to "da-DK".
    Culture "da-DK" uses "," as decimal separator and "." as thousand separator.

    When entering values the numerictextbox accepts the decimal separator but the validation fails.
    When changing culture to "en-US" the validation is successful.

    I have stripped down my code to this example that illustrates this behaviour.
    The numerictextbox elements are as rendered by the Kendo UI libraries.

    If I omit the form element the validation error message is not shown. Doesn't validation occur when there is no form element?

    Do you have any clue to what causes this? Is it a bug in Kendo or in my code?

    Regards,
    Kristian Vad Nielsen

  6. kvn
    kvn avatar
    3 posts
    Member since:
    Dec 2009

    Posted 03 Oct 2013 Link to this post

    Hello Alexander,

    You will notice, in the example above, that I use culture "de-DE" instead of "da-DK" since the culture script "kendo.culture.da-DK.js" apparently
    doesn't exist alongside the other culture scripts. I doesn't make much difference in this example since they both use same decimal separator.

    Regards,
    Kristian Vad Nielsen
  7. Alexander Popov
    Admin
    Alexander Popov avatar
    1416 posts

    Posted 07 Oct 2013 Link to this post

    Hello Kristian,

    This happens because jQuery Unobtrusive Validation does not support globalization out of the box. Although you've set the client-side culture using Kendo and configured the widgets to properly work with a comma as a decimal separator, jQuery validation still tries to validate the numbers using a period as a separator. For more information on how to globalize jQuery validation I would recommend you to check the following blog post:


    Regards,
    Alexander Popov
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top
UI for ASP.NET MVC is VS 2017 Ready