Else and alerts

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.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices




Reply
 
LinkBack Thread Tools
  #1  
Old Oct 3rd, 2005, 21:28
Junior Member
Join Date: Oct 2005
Location: Anna TX
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
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>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old Oct 3rd, 2005, 21:41
Junior Member
Join Date: Sep 2005
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Code: Select all
else {
alert("Passwords do not match!");
document.forms['myForm'].reset();
}
should work.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old Oct 4th, 2005, 13:26
Junior Member
Join Date: Oct 2005
Location: Anna TX
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
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();
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old Oct 4th, 2005, 14:54
Junior Member
Join Date: Sep 2005
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Code: Select all
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!");
document.forms['myForm'].reset();
}

}
That should help a bit more.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5  
Old Oct 4th, 2005, 19:44
Junior Member
Join Date: Oct 2005
Location: Anna TX
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6  
Old Oct 4th, 2005, 20:07
Junior Member
Join Date: Sep 2005
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
In the else{} block, add to the end:
return false;


That might fix it. . .
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7  
Old Oct 4th, 2005, 21:15
Junior Member
Join Date: Oct 2005
Location: Anna TX
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
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();
}

}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #8  
Old Oct 5th, 2005, 05:16
Junior Member
Join Date: Sep 2005
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
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. :-)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #9  
Old Oct 5th, 2005, 18:44
Junior Member
Join Date: Oct 2005
Location: Anna TX
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
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?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
else, alerts

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

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


All times are GMT. The time now is 23:55.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42