Can someone tell me what’s wrong with the following code? It’s suppose to show the telephone number only if it consists out of numbers, but if you enter 123e456 it displays it even though it is not a valid number because it contains an alphabet character.
<!DOCTYPE html
PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”
“
<html>
<head>
<title>Telephone Number</title>
<script langauge=”Javascript”>
var tel
</script>
</head>
<body>
<script language=”JavaScript”>
var tel= prompt(“Please enter your telephone number:”, “”)
if(isNaN(tel))
{
document.writeln(“You must enter only numbers.”)
} if(tel.length<7)
{
document.writeln(“You did not enter a telephone number.”)
} if(tel.length>7)
{
document.writeln(“You did not enter a telephone number.”)
} else {
document.writeln(“You entered:” +tel)
}
</script>
</body>
</html>