Program:
Output:
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
function checkNum() {
var num = document.getElementById('num').value;
try {
if (num.length != 10) {
throw ("Please enter a 10 digit number");
} else {
document.write(num);
}
} catch (e) {
alert("Error:" + e)
} finally {
document.write("<br> Always")
}
}
</script>
</head>
<body>
<form>
Enter any number: <input type="text" id="num">
<input type="button" onclick="checkNum()" value="Check">
</form>
</body>
</html>
Output:
