Code:
-- assume we don't have a valid entry
set gotNum to false
repeat until gotNum is true
-- ask the user
set theDialog to display dialog "Enter a number" default answer "0"
--get the text
set theInput to text returned of theDialog
try
-- can it be coerced to a number?
set theNum to theInput as number
-- is it bigger than 0?
if theNum < 0 then
-- warn the user the number is negative
display dialog "Oops, that was negative"
else
-- if we get here, we have a positive number
set gotNum to true
end if
on error
-- if we get here, there was a problem
-- most likely in converting the input to a number
display dialog "Oops, that wasn't a number"
end try
end repeat
The comments cover most of the issues, but the basic principle is that it uses AppleScript's ability to coerce strings into numbers. If it can't because the string contains non-digits, it fails and the 'on error' statement is run.
The code is enclosed in a repeat loop that keeps running until a valid number is obtained.
Change the line 'set theNum to theInput as number" to "... theInput as integer" if you want to ensure you get whole numbers and not real numbers.