hi i want to validate my id field that if someone enter data other than id in the id field it show message that its not id.i have little bit of logic to validate but i am not getting the point that how to validate that it only accept numeric value.below is my code please help

<html>
<head>




<link rel="stylesheet" type="text/css" href="css/enter_Subject.css" />

</head>

<body>


                  <div id="form2">
                    <center id="Center">
                    Enter Subject
                    </center>
                    </div>
    
           
                    <hr id="new">
                    </hr>
                    <center class="Center">
            
<form id="class" class="class" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"  style="width:600px">
 
                   <div class="test">
                       
    
                    <select class="form-dropdown" style=" 
    width: 150px;" >
                    <option>  </option>
                    <option value="Option 1"> Option 1 </option>
                    <option value="Option 2"> Option 2 </option>
                    <option value="Option 3"> Option 3 </option>
                    </select>
               
                    <label class="label1"> Go to
                    </label>
                    </div>
  
                    <p class="name">  
                    <input type="text" id="id2" name="id2" placeholder="enter id"/>  
                    <label for="name"><i>id</i></label>  
                    </p>
                    
                    <p class="name">  
                    <input type="text"id="subject_name" name="subject_name" placeholder="enter subject"/>  
                    <label for="name"><i>Subject</i></label>  
                    </p>  
 
                    <p class="submit">  
                    <input type="submit"  id="submit"value="Submit"  />  
                    </p>  
  
                    </form> 
                    </center>

                    <div id="msg"></div>
                    <color> <horizontal offset> <vertical offset> <blur> 


</body>
</html>

there are a couple of ways of validating your id field, you can pass it in (as n in this case) returns boolean true / false when called.

function isNumber(n) {
  return !isNaN(parseFloat(n)) && isFinite(n);
}
// or since you should be able to find your id field 
function isNumber() {
  var id = document.myform.id.value;
  return !isNaN(parseFloat(id)) && isFinite(id);
}