Skip to Content

Regex to allow max 10 digits followed by only one comma and 3 more digits

Nov 14, 2017 at 09:00 AM


avatar image


i trying to validate entered data into input control on live change.

Input control should accept max 14 characters - 10 digits followed by comma and 3 more digits.

For example: 1234567890,657

There has to be only one comma, another comma should not be allowed.

I tried the following code:

var enteredVal = oEvent.getParameter("value");
var filteredVal = enteredVal.replace(/[^\d+(,{1}\d{3})?$]/g, '');

I am able to enter only digits and comma upto 14 characters as the max length of control is set to 14.

Comma can come at any position, but after comma max 3 digits are allowed.

Few more examples:




How do i restrict second occurrence of comma and restriction digits after comma.

Please suggest possible options.



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

0 Answers