Number input replacing decimal comma with dot

Sebastian Busek

After posting the form with an input of type 'number' and value "1,5", the browser (Chrome 43.0.2357.130, FF 38.0.5) is sending the number with a dot as decimal separator, but the input has attribute lang="cs" (in Czech Republic we use decimal comma), so for ASP.NET MVC it's the incorrect format.

How can I set the browser (form/input) to send what user really filled ("1,5" in my case)?

The form data sent from the browser:

__RequestVerificationToken:KJG1yJxm-1EcUHPwgvr0gPpkyoEHHHcTfSu6hHvaKDA_XKHTzWfPfUJtAr11gNiR_euG_jWYmXlrMO7dyhSf7g4K74eOVTtEzLQ1OdrTLZ_cbIyyYj5vrgxlk81JzuhM0
PaymentMethodId:8
PaymentMethod:Direct payment
Provider:Direct payment
MinAmount:1,00000000
MaxAmount:5000,00000000
Amount:1.5
Sebastian Busek

Oukey, it looks like I found workaround, but look at it as example how you can handle similar issue...

public class ApolloModelBinder : DefaultModelBinder
{
    protected override void BindProperty(ControllerContext controllerContext, ModelBindingContext bindingContext, PropertyDescriptor propertyDescriptor)
    {
        var request = controllerContext.HttpContext.Request;

        decimal i;
        var value = request.Form[propertyDescriptor.Name];
        if (propertyDescriptor.PropertyType == typeof(decimal) && decimal.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out i))
        {
            propertyDescriptor.SetValue(bindingContext.Model, i);
            return;
        }

        base.BindProperty(controllerContext, bindingContext, propertyDescriptor);
    }
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

AngularJS decimal input: change comma to dot

From Dev

Difference between decimal number with comma and dot Javascript

From Dev

Regex for decimal number dot instead of comma (.NET)

From Dev

Replacing comma with dot Char

From Dev

Replacing dot with comma in Ruby spreadsheet

From Dev

Decimal dot and thousands separator used both in input type number

From Dev

Regex a decimal number with comma

From Dev

Regex a decimal number with comma

From Dev

Regex for replacing times with comma to a dot in Python

From Dev

Replacing dot with comma from a dataframe using Python

From Dev

Replace comma with dot in a input Javascript

From Dev

Replace comma with dot in a input Javascript

From Dev

On setting float value in number input with jQuery, the number has comma and I want a dot

From Dev

NumericUpDown: accept both comma and dot as decimal separator

From Dev

Allow dot and comma in numbers, not only for decimal

From Dev

String to decimal conversion: dot separation instead of comma

From Dev

Regex for formatting comma for decimal places and dot for thousands

From Dev

NumericUpDown: accept both comma and dot as decimal separator

From Dev

C# aspx decimal thousand with comma and decimal with dot

From Dev

Jquery input number with comma

From Dev

Jquery input number with comma

From Dev

New Webkits convert decimal comma to ~ dot and vice versa in number-type inputs. Javascript name of that browser feature?

From Dev

New Webkits convert decimal comma to ~ dot and vice versa in number-type inputs. Javascript name of that browser feature?

From Dev

Number with decimal input in React?

From Dev

What determines if input values are output with a dot or a comma?

From Dev

Extracting a number with dot and comma using regex

From Dev

Java floating point number in comma instead of dot

From Dev

How to replace number dot (.) with a comma (,) using java

From Dev

Replacing comma by dot only in numbers in a texteditor using search and replace function

Related Related

  1. 1

    AngularJS decimal input: change comma to dot

  2. 2

    Difference between decimal number with comma and dot Javascript

  3. 3

    Regex for decimal number dot instead of comma (.NET)

  4. 4

    Replacing comma with dot Char

  5. 5

    Replacing dot with comma in Ruby spreadsheet

  6. 6

    Decimal dot and thousands separator used both in input type number

  7. 7

    Regex a decimal number with comma

  8. 8

    Regex a decimal number with comma

  9. 9

    Regex for replacing times with comma to a dot in Python

  10. 10

    Replacing dot with comma from a dataframe using Python

  11. 11

    Replace comma with dot in a input Javascript

  12. 12

    Replace comma with dot in a input Javascript

  13. 13

    On setting float value in number input with jQuery, the number has comma and I want a dot

  14. 14

    NumericUpDown: accept both comma and dot as decimal separator

  15. 15

    Allow dot and comma in numbers, not only for decimal

  16. 16

    String to decimal conversion: dot separation instead of comma

  17. 17

    Regex for formatting comma for decimal places and dot for thousands

  18. 18

    NumericUpDown: accept both comma and dot as decimal separator

  19. 19

    C# aspx decimal thousand with comma and decimal with dot

  20. 20

    Jquery input number with comma

  21. 21

    Jquery input number with comma

  22. 22

    New Webkits convert decimal comma to ~ dot and vice versa in number-type inputs. Javascript name of that browser feature?

  23. 23

    New Webkits convert decimal comma to ~ dot and vice versa in number-type inputs. Javascript name of that browser feature?

  24. 24

    Number with decimal input in React?

  25. 25

    What determines if input values are output with a dot or a comma?

  26. 26

    Extracting a number with dot and comma using regex

  27. 27

    Java floating point number in comma instead of dot

  28. 28

    How to replace number dot (.) with a comma (,) using java

  29. 29

    Replacing comma by dot only in numbers in a texteditor using search and replace function

HotTag

Archive