Skip to Content
avatar image
Former Member

Number Format

Hello Experts,

I have an input field called "OpenQuantity" in my application where user can enter only number ( float or decimal are also allowed). I have put a validation from UI side to check whether an end user is entering number or not by using javascript method isNaN(). My applicatiion would be used in different countries. In France, they will use comma instead of decimal where if the user entered 5,6 my application will throw an error that it is not number. So mean to say isNaN() is not working for french language.

Could anyone please help me or suggest what kind of validation I can write in my application so that it can work for all the countries.

Regards,
Abhimanyu

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Sep 03, 2017 at 05:43 PM

    what about a regular expression for numbers and either a dot or a comma in between:

    something like

    /\d+(\.|\,){1}\d+/g

    1 or more digits followed by a dot/comma followed by 1 or more digits

    hope it works

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 03, 2017 at 05:44 PM

    how about a regular expression - something like a digit followed by a comma or a period followed by a digit

    //\d+(\,|\.){0,1}\d+/g

    something like that - hope it works

    Add comment
    10|10000 characters needed characters exceeded