I want to show the 'valid' message if the variable value is
- not numeric with length of 10
- an empty string (
"")
if(isNaN(num) && num !="" && num.length!=10)
{
alert("invalid");
}
else
{
alert("valid");
}
But this code shows 'digits which length is not 10' as valid. But whether it is numeric or not numeric, if its length is not 10 it should be invalid.
lengthis a property valid for string. What do you mean by length here? The number of digits ?