title: How to call javascript function in php code?
body: <p>on my login form, i am putting server side validations and if error occurs i want to display those error just below the validated control. Now for this, i am trying to call javascript function to show validation message in php code but not able to call.</p>
  
  <pre><code>&lt;?php
  
  if($_SERVER['REQUEST_METHOD'] == 'POST')
  {
  if($_POST['txtUsername']=='')
  {
      //here i want to call javascript function to display message    
  }
  }
  ?&gt;
   &lt;form action="login.php" method="POST"&gt;
  
   Username &lt;input type="text" size="30" name="txtUsername" id="user" /&gt;&lt;br /&gt;
  
   Password &lt;input type="password" size="30" name="txtPassword" id="pass" /&gt;&lt;br /&gt;
  
   &lt;input type="submit" value="Login" name="loginSubmit"/&gt;
  
  &lt;/form&gt;
  
  
  &lt;script type="text/javascript"&gt;
  
     function showMessage(value)
     {
      document.getElementById(value).innerHTML= value+"can not be empty."; 
     }
     &lt;/script&gt;
  </code></pre>
  
  <p>Please tell me how to display server side validation just below the validated control in form.</p>