This is a discussion on "Else and alerts" within the JavaScript Forum section. This forum, and the thread "Else and alerts are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
Else and alerts
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
#1
|
|||
|
|||
|
Else and alerts
Question- I have a page where a user can create a username and password. The username and password is stored in an access database. When the user hits submit on the fist page it calls an asp page that enters it in the access database. The issue I have is with verifying the passwords. I get it to popup the error when the passwords don’t match but I can get it to reset the page so the user can reenter there information. This is the code I’m user
<html> <head> <title>Account Create</title> <script language="javascript"> <!-- function checkMe() { if (document.myForm.T2.value == document.myForm.T3.value) { document.myForm.PWD.value=document.myForm.T2.value ; document.myForm.submit(); } else alert("Passwords do not match!"); } //--> </script> <meta name="Microsoft Theme" content="safari 011"> </head> <body> <p style="background-color: #FF0000; color: #FF0000"></p> <p align="center">Please enter your Email Address and password.</p> <form method="POST" name="myForm" action="M_Create_account.asp"> <input type="hidden" name="PWD"> <table border="5"> <tr> <td>Email Address</td> <td><input type="text" name="T1" size="20"></td> </tr> <tr> <td bordercolorlight="#FF0000" bordercolordark="#FF0000">Password</td> <td bordercolorlight="#FF0000" bordercolordark="#FF0000"><input type="password" name="T2" size="20"></td> </tr> <tr> <td>Repeat Password</td> <td><input type="password" name="T3" size="20"></td> </tr> <tr> <td colspan="2" align="center" bordercolorlight="#FF0000" bordercolordark="#FF0000"> <p align="center"> <input type="submit" onClick="checkMe()" value="Submit" name="account.asp"> <input type="reset" value="Reset"> </p> </td> </tr> </table> </form> <p align="center" style="background-color: #FF0000; color: #FF0000"></p> </body> </html> |
|
|
|
#2
|
|||
|
|||
|
|
#3
|
|||
|
|||
|
Else and alerts
I added the lines but it still didn’t work. It popup the error that the passwords don’t match but It does resets fields. I’m not sure about the open and close brackets.
} else alert("Passwords do not match!"); document.forms['myForm'].reset(); } |
|
#4
|
|||
|
|||
|
|
#5
|
|||
|
|||
|
Else and alerts
I copied and pasted your suggestion and it’s still not working. I get the Pop up that the passwords don’t match, instead of resetting the form it brings me to the next page saying no updates and give me a lick to my next page.
|
|
#6
|
|||
|
|||
|
In the else{} block, add to the end:
return false; That might fix it. . . |
|
#7
|
|||
|
|||
|
Still no good, I tried with the return at the end and I also tried with it in the middle as you can see. Thanks for your help on this.
<!-- function checkMe() { if (document.Account_Create.T2.value == document.Account_Create.T3.value) { document.Account_Create.PWD.value=document.Account _Create.T2.value; document.Account_Create.submit(); } else { alert("Passwords do not match!"); return false; document.forms['Account_Create'].reset(); } } |
|
#8
|
|||
|
|||
|
I asked someone to move this topic to the JavaScript forum since this should be a topic for that forum. I'm currently out of ideas. I hope you get more help there. :-)
|
|
#9
|
|||
|
|||
|
Else and alerts
Thanks rpgfan3233
I just noticed that it does clear the form but instead of staying on the same page it jump to the next page, how do I get it not to jump to the next page? |
![]() |
| Tags |
| else, alerts |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Alerts: Only one wanted - How to? | jswebdev | JavaScript Forum | 4 | Dec 17th, 2006 21:03 |
| Please help me add some random alerts to my code | meddow | JavaScript Forum | 0 | Nov 24th, 2006 01:04 |