text: Q:
  
  the onblur and onsubmit function are not working could someone please help me out here
  
  i am working on project using php,html,javascript. i am using on blur and onsubmit both the functions to provide dynamic kind of feel for errors. the following logic is working in every file except for this one .
  The form functions like onsubmit and onblur are not working , i used an alert also to check but its not being called  could someone please check and tell me where i am going wrong    
  <script language="Javascript">
  //the flags are used to check if all the fields are filled and none is empty
  var flag1;
  var flag2;
  var flag3;
  
  function test(){
  
      alert("fn called");
      return true;
  
  }
  function fun1() 
  {
  var donated_date=document.forms["myform"]["donated_date"];
  if(donated_date==null||donated_date=="")
  {   
      document.getElementById('ddate').innerHTML = "Choose the date of your last donation " ;
      document.getElementById('ddate').style.display = "block" ;
      flag1=false;
      return false;
  
  }
  document.getElementById('ddate').style.display = "none" ;
  flag1=true;
  return true;
  
  }
  function fun2()
  {   
  var location=document.forms["myform"]["location"];
  if(location==null||location==""||!isNaN(location))
  {
      document.getElementById('loc').innerHTML = "Mention the location of your last donation " ;
      document.getElementById('loc').style.display = "block" ;
  
      flag2=false;
      return false;
  }
  document.getElementById('loc').style.display = "none" ;
  flag2=true;
  return true;
  
  function fun3()
  {   
  
  var hospital_name=document.forms["myform"]["hospital_name"];
  
  if(hospital_name==null||hospital_name==""||!isNaN(hospital_name))
  {
      document.getElementById('hname').innerHTML = "Mention the Hospital Name where you last donated " ;
      document.getElementById('hname').style.display = "block" ;
      flag3=false;
      return false;
  }
  document.getElementById('hname').style.display = "none" ;
  flag3=true;
  return true;
  
  }
  
  function validate()
  {
  alert("hello");
  
  }
  </script>
            <form name="myform" method="post" action="o.php"  onsubmit="return validate()">
            <table width="94%" cellpadding="3px" class=" lastDonatedblood_table" cellspacing="0" style="border: 1px solid #CCCCCC;margin: -18px 0 14px 6px;width: 98.5%;">
              <tr>
                      <td style="text-align:left;">Donated Date:</td>
                      <td style="text-align:left;">
  <input type="text" name="donated_date" id="donated_date"  onblur="return test();" style="width:300px;"/>
                          <div id="ddate"></div>
                      </td>
  
                  </tr>
                  <tr>
                      <td style="text-align:left;">Location:</td>
                      <td style="text-align:left;"><textarea  name="location" id="location"  onblur="return fun2();" style="width:300px;"></textarea></td>
                  </tr>
                  <center></center>
                  <tr>
                      <td style="text-align:left;">Hospital Name:</td>
                      <td style="text-align:left;"><input type="text" name="hospital_name" id="hospital_name"  onblur="return fun3();" style="width:300px;"/></td>
                  </tr>
                  <center><div id="hname"></div></center>
                  <tr>
                      <td style="text-align:left;">Type of Donation:</td>
                      <td style="text-align:left;">
                          <select title="" name="donationtype" id="donationtype"  style="width:317px;">
  
                 <option value="blood">Blood</option> 
                 <option value="platelets">Platelets</option>
                 </select>
                      </td>
                  </tr>
                  <tr >
                    <td colspan="2">
                       <input name="submit" id="submit" value="ADD" type="submit" style="margin-top:5px; margin-left:185px; font-size:14px; width:100px;">
                    </td>
                  </tr>
              </table>
              </form>
  
  A:
  
  you are missing closing curly bracket (function close) for fun2(),
  function fun2()
  {   
  var location=document.forms["myform"]["location"];
  if(location==null||location==""||!isNaN(location))
  {
      document.getElementById('loc').innerHTML = "Mention the location of your last donation " ;
      document.getElementById('loc').style.display = "block" ;
  
      flag2=false;
      return false;
  }
  document.getElementById('loc').style.display = "none" ;
  flag2=true;
  return true;
  } <-- added closing curly bracket here 
  
  Check in console and you will get the error
  
  