properly check bounds to prevent UI bug

In the two browsers I checked (Firefox and Safari), pressing return to
close the JS alert (for an invalid/out-of-bounds tip) re-triggers tip
submission since the tip input field is still focused. Before this
commit I worked around that by focusing on the confirm/cancel links,
but this adds a proper solution by doing bounds checking.