We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,745 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

I want to validate new password with repeat password befor user press submit.

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>
3
Contributors
6
Replies
4 Months
Discussion Span
2 Years Ago
Last Updated
7
Views
Question
Answered
ayesha789
Posting Pro in Training
496 posts since Jun 2009
Reputation Points: 17
Solved Threads: 7
Skill Endorsements: 5

please tell me

ayesha789
Posting Pro in Training
496 posts since Jun 2009
Reputation Points: 17
Solved Threads: 7
Skill Endorsements: 5

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>
samaru
a.k.a inscissor
Team Colleague
1,256 posts since Feb 2002
Reputation Points: 262
Solved Threads: 18
Skill Endorsements: 21
Question Answered as of 3 Years Ago by samaru

Can I Use light box for showing message.

ayesha789
Posting Pro in Training
496 posts since Jun 2009
Reputation Points: 17
Solved Threads: 7
Skill Endorsements: 5

What do you mean by "light box"?

samaru
a.k.a inscissor
Team Colleague
1,256 posts since Feb 2002
Reputation Points: 262
Solved Threads: 18
Skill Endorsements: 21

light box using jquey.

ayesha789
Posting Pro in Training
496 posts since Jun 2009
Reputation Points: 17
Solved Threads: 7
Skill Endorsements: 5

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

almostbob
Nearly a Senior Poster
3,280 posts since Jan 2009
Reputation Points: 585
Solved Threads: 398
Skill Endorsements: 7

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.3184 seconds using 2.66MB