The validating phone number is an important point while validating an HTML form.
The check on the length is for a special case involving empty strings.
// Whitespace strings: Is Numeric(' ') == true; Is Numeric('\t\t') == true; Is Numeric('\n\r') == true; // Number literals: Is Numeric(-1) == false; Is Numeric(0) == false; Is Numeric(1.1) == false; Is Numeric(8e5) == false; Arrrgh! Reg Ex is icky for this, and I'm not talking just performance.
It's so easy to make subtle, impossible to spot mistakes with your regular expression.
I can it to work if the input is only digits, but when i type any characters after a number, it will still validate etc.
Unlike many other programming languages, Java Script does not define different types of numbers, like integers, short, long, floating-point etc.