This allows us to focus upon it via the helper function, as opposed to passing the value of the field only.
Email is similar—we couldn't expect to know if the user name or domain name was real.
This makes our code more portable, and saves typing. Let’s focus on the field that triggered the error, instead of making them find it on their own.
Ok, that was pretty good, but don’t you feel that it’s a little too much code for every field?
This function performs the simple validation of a number — it checks whether the field contains digits only, and optionally, if it is within a given range.
You’ll note that this code passes the error message as a parameter.