SyntaxFix
Write A Post
Hire A Developer
Questions
You need the * so it says "zero or more of the previous character" and this should do it:
*
var reg = new RegExp('^\\d*$');