Use the following regex:
^[0-9]{0,2}$
You almost had it — the ^ and $ characters are anchors that match the beginning and end of the string, respectively.
For a more in-depth discussion on anchors, see here:
[Anchors] do not match any character at all. Instead, they match a position before, after or between characters. They can be used to “anchor” the regex match at a certain position.