There is already an other post for this but i can't comment on it. Sorry for that.
I used
var pattern = new RegExp('^[1-9]\d*$');
var result = fieldValue.search(pattern);
but i get a "-1" if I put 12
It allows me just number from 1 to 9 and no more.
Is there something wrong?