By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,796 Members | 1,240 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,796 IT Pros & Developers. It's quick & easy.

Logic Error on Javascript

P: 83
Expand|Select|Wrap|Line Numbers
  1. <script language="javascript">
  2. <!--
  3. function ValidatePwd()
  4. valid = true;
  5. var NewP=document.getElementById("NPwd").value;
  6. var OldP=document.getElementById("OPwd").value;
  7. if (NewP.value == OldP.value)
  8. {
  9. alert("Change into new password,please!");
  10. document.getElementById("NPwd").value="";
  11. valid = false;
  12. }
  13. return valid;
  14. }
  15. //-->
  16. </script>
  17. <body>
  18.  
  19. <table border=0 cellspacing=0 cellpadding=0 width=100% height=100%>
  20. <tr align=center valign=top>
  21.  <td>
  22.     <form method=post action=/Intranet/hr/Change_Password_db.asp  id=form1 name=form1 onSubmit="return ValidatePwd();">
  23.      <BR><BR><BR>
  24. ...
  25. ....
  26. .....
  27. <td> <input type="password" maxlength="20" id="NPwd">&nbsp;&nbsp; <input type="submit" value="Submit" id="submit1" name="submit1" style="WIDTH: 80px; HEIGHT: 24px"></td>
  28.  
Help, the javascript always get alert wether it's true or not
Sep 25 '08 #1
Share this Question
Share on Google+
4 Replies


P: 93
Friend I really donot undeerstand why you have used this<-- no need second thing "var OldP=document.getElementById("OPwd").value; " from where you are fetching the id OPwd as this is nowhere in your code.Please make everything clear and transparent.
Sep 25 '08 #2

acoder
Expert Mod 15k+
P: 16,027
You should be comparing NewP and OldP, not NewP.value and OldP.value because NewP and OldP are already set to the value!
Sep 26 '08 #3

P: 83
Hi Hi... got mistake coz long time no longer coding on asp
I have make the correction on OldP and NewP with the thing OldP.value and NewP.value
thanks guys anyway
Oct 9 '08 #4

acoder
Expert Mod 15k+
P: 16,027
So that means it's working now?
Oct 9 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.