in reply to integer validation
Think "What's a representation of an integer?" One answer is "a string of only digits", but that won't catch the negative integers. There *might* be a "-" at the front of such a string. So you want to see that the string matches that pattern. For pattern matches, use a regular expression.
Here's some info that ought to help you figure it out for yourself:
^ says "match at the beginning of the string"
? says "match 0 or 1 of the previous pattern"
\d says "match digits"
$ says "match at the end of the string
So, your pattern will start with ^ and end with $.
That should be enough to get you started.
HTH.
|
|---|