Using a regular expression to validate whether input has any non digits in it
Simply:
function validInteger(theNumber){
return theNumber.match(/^\d+$/) && parseInt(theNumber) > 0;
}
Live DEMO
Or even simpler with regex
only as suggested by @Eric:
return /^[0-9]\d*$/.test(theNumber);
Live DEMO
Update:
An excellent cheat sheet. The link died after 5 years, sorry.