title: Validate if an input only contains numeric values - Javascript
body: <p>I am currently using the script below to take my inputs and convert them to what I want with some validation included.
  I have got my server side validation set up and would like to have some client side also, I have validated the lengths of the inputs but now need to ensure that they only contain numbers. This is for the Variables day, month and year. I have tried using IsNumeric() but to no avail</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  function timeMachine() {
  
      var day     = $("#date_day").val();
      var month = $("#date_month").val();
      var year    = $("#date_year").val();
  
      if (day == "" &amp;&amp; month == "" &amp;&amp; year != ""){
          if (year.length != 4){
              alert("Please enter a valid year!");
          } else{
              window.location = "/date/" + year ;
          }   
      } else if (day == "" || month == "" || year == ""){
          alert("Please enter a full date!");
      } else{
          var myDate = new Date(year, month-1, day);
  
          var monthNames = [ "january", "february", "march", "april", "may", "june","july", "august", "september", "october", "november", "december" ];   
  
          window.location = "/date/" + year + "/" + monthNames[myDate.getMonth()] + "/" + day;
      }
      return false;
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>Thoughts?</p>