I would like to allow 0 or positive integers as input. The best solution I saw was
/^[0-9]+$/.test(input)
but this expression will allow the user to use "010"
, so I changed the expression to
/^(0|[1-9]+[0-9]*)$/.test(input)
Is that correct? Does this expression handle every input?