hi this is my code.
I want to validate new password with repeat password befor user press submit.

<p align="center">To reset your password, provide your current password</p>
<form id="form1"  name="form1" method="post" action="pcq.php">
    
     <table border="0" align="center" class="mytable2" style="margin-left:175px"  >
	 <tr>
         <td>Current Password</td>
         <td>
         
        <input type="password" name="oldpass" style="width:150px;" />
         
         </td>
       </tr>
       <tr>
         	 <? $user=$_SESSION[myusername] ?>
		          <td><input type="hidden" name="usr" id="usr" value="<?php echo $user; ?>"style=" width:150px;" />
         </td>
       </tr>
       <tr>
         <td>New Password</td>
         <td><input type="password" name="pass"  style="width:150px;" /></td>
       </tr>
	   <tr>
         <td>Repeat New Password</td>
         <td><input type="password" name="rpass"  style="width:150px;" /></td>
       </tr>
       <tr>
       
       
       <tr>
	   <td>
	   </td>
<td > <input type="submit" value="submit"  >
 <input type="reset" value="Reset"></td>

</tr>

       
       
     </table>
   </form>

please tell me

What will trigger the validate() function? When you tab or switch the cursor to another textbox? This is what this does.

<html>
<head>
  <title></title>

<script language="javascript">

function validate() 
{
  // Verify that both passwords put in match. 
  if ( ( document.getElementById("password").value != document.getElementById("passwordverify").value ) ||
  document.getElementById("password").value.length == 0   )
  {
    alert("Both passwords must match.");
    // return false;  
  }

}

</script>
  
</head>

<body>



<p align="center">To reset your password, provide your current password</p>
<form id="form1"  name="form1" method="post" action="pcq.php">
    
     <table border="0" align="center" class="mytable2" style="margin-left:175px"  >
	 <tr>
         <td>Current Password</td>
         <td>
         
        <input type="password" name="oldpass" style="width:150px;" />
         
         </td>
       </tr>
       <tr>
         	    <? $user=$_SESSION[myusername] ?>
		          <td><input type="hidden" name="usr" id="usr" value="<?php echo $user; ?>"style=" width:150px;" />
         </td>
       </tr>
       <tr>
         <td>New Password</td>
         <td><input type="password" name="pass"  style="width:150px;" id="password" /></td>
       </tr>
	   <tr>
         <td>Repeat New Password</td>
         <td><input type="password" name="rpass"  style="width:150px;" id="passwordverify" onblur="validate()"/></td>
       </tr>
       <tr>
       
       
       <tr>
	   <td>
	   </td>
<td > <input type="submit" value="submit"  >
 <input type="reset" value="Reset"></td>

</tr>

       
       
     </table>
   </form>


</body>
</html>

Can I Use light box for showing message.

What do you mean by "light box"?

light box using jquey.

users may submit without filling in either password input so

<form id="form1"  name="form1" method="post" action="pcq.php" onsubmit='validate();'>

yes you can use a lightbox popup
instructions are in the lightbox docs,
RTFM

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.