$regex = '/^(.+){,16}$/'
Nothing is matching, everything fails!
There are 2 problems:
{,16}
matches the characters {,16}
literally, you should use {0,16}
.+{,16}
you should use .{0,16}
Regex that should work for you:
$regex = '/^.{0,16}$/'; // will match empty input also