Regular Expression to validate comma separated numbers using javascript

Today i got situation to validate text field containing comma separated numbers. I know how to validate numbers alone. But don’t know how to validate numbers with comma separated and each number should be 8 digits.

For example, 1234678,54872659,84567892,....

I searched google but didn’t find it and finally i got solution from my friend…

Here is the regular expression to do this trick,



<script language="javascript">
var pattern = /^(?:\s*\d{8}\s*(?:,|$))+$/;
var testvalue = document.getElementById('checkNumber').value;
} else {


More explanations on this regular expression, please check here

Hope this will be useful to you all.

Author: Vinodkumar Saravana.

1 Comment

  1. ram said,

    March 14, 2019 at 6:31 am

    thanks for posting it is use full for me, i searched so many times but not able to get solution, finally happy with this is.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: