
if three text box value in my program i want to check the three input boxes values and display greatest two values

<html>
<script>
function check(){
var n1=document.getElementById("num1").value;
var n2=document.getElementById("num2").value;
var n3=document.getElementById("num3").value;
if((!isNaN(n1))&&(!isNaN(n2))&&(!isNaN(n3))){
var num1=parseInt(n1);
var num2=parseInt(n2);
var num3=parseInt(n3);
var secondhighest;
var highest=Math.max(num1,num2,num3);
if(highest==num1){
secondhighest=Math.max(num2,num3);
}
if(highest==num2){
secondhighest=Math.max(num1,num3);
}
if(highest==num3){
secondhighest=Math.max(num1,num2);
}
alert("Greatest Number: "+highest+" and Second Greatest Number: "+secondhighest);
}
else{
alert("Entered values are not an integer!");
var n1=document.getElementById("num1").value=" ";
var n2=document.getElementById("num2").value=" ";
var n3=document.getElementById("num3").value=" ";
}
}
</script>
<table>
<tr><td>Enter Number1</td><td><input type="text" id="num1"></td></tr>
<tr><td>Enter Number2</td><td><input type="text" id="num2"></td></tr>
<tr><td>Enter Number3</td><td><input type="text" id="num3"></td></tr>
<tr><td></td><td><input type="button" value="Check" onclick="check();"></td></tr>
</html>