Edit: Lost the race to
Re: Need a regex.., which is also slightly better :)
Try a more grouped approach:
/^([+]|[-])?[0-9]{0,3}(\.[0-9]{1,3})?$/
First the start of the line:
^
then an optional + or - sign, with the + enclosed in [] to avoid interpretation:
([+]|-)?
then 0-3 digits:
[0-9]{0,3}
then an optional group of a period followed by 1-3 digits, with the period escaped in another way to avoid interpretation:
(\.[0-9]{1,3})?
and finally the end of the line:
$