title: How to check date in dd-Mon-yyyy format in javascript?
body: <p>At First I use to pass data to action class from java script But I want to do in java script How to do?</p>
  
  <p>Jsp java script:</p>
  
  <pre><code>$('#nwr_fa_dob').keypress(function(event)
         {
            $('#nwr_fa_gender').attr('disabled',false);
           var keycode = (event.keyCode ? event.keyCode :event.which);
           var dob= $('#nwr_fa_dob').val();
           if(keycode == '13' || keycode =='40')
           {
              $.ajax({
                  type: "POST",              
                  dataType: "json",
                  url: "dob_details",
                  data: {dob:dob},        
                  success: function(response)
                  {
                      $('#nwr_fa_dob').val(response.dob);
                      if($('#nwr_fa_dob').val()==null || $('#nwr_fa_dob').val()=='')
                      {
                          alert("You Will Give Age or DateFormat of dd-MMM-yyyy(Ex : 18-Mar-1990)");
                          $('#nwr_fa_dob').val('');
                          $('#nwr_fa_dob').focus();
                          }
                      else
                      {
                          $('#nwr_fa_dob').val(response.dob);
                          $('#nwr_fa_gender').focus();
                          }
                      }
                  });
              return false;
              }
           if(keycode=='38'){
               $('#nwr_fa_fsname').focus();
               return false;
               }
           });
  </code></pre>
  
  <p>Java Code:</p>
  
  <pre><code>public String dob_fetchdate() {
          try {
              if (dob.length() == 11) {
                  Date dat = ymd.parse(dob);
                  if (ymd.format(dat).equals(dob)) {
                      dob = dob;
                  } else {
                  dob = null;
                  }
              } else if (dob.length() == 10) {
                  dob = null;
              } else if (dob.length() == 2) {
                  String date = DateNow.substring(7, 11);
                  String year = String.valueOf(Long.valueOf(date)
                          - Long.valueOf(dob));
                  dob = DateNow.substring(0, 7).concat(year);
              } else {
                  dob = null;
              }
              return "success";
          } catch (Exception ex) {
              System.out.println("Dob Error =" + ex);
              return "error";
          }
      }
  </code></pre>