Skip to Content
0

Number Format

Mar 30, 2017 at 06:32 AM

43

avatar image
Former Member

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

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Sergio Guerrero Sep 03, 2017 at 05:43 PM
0

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

Share
10 |10000 characters needed characters left characters exceeded
Sergio Guerrero Sep 03, 2017 at 05:44 PM
0

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

Share
10 |10000 characters needed characters left characters exceeded