codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  Functions  lWalsh at 11:38 on Tuesday, March 02, 2004
 

I want to write a simple function to compare a password with the confirmation password that the user provides. I want to create a simple function to make sure that the code works before I connect the code to the database. I am hard coding teh values in the variables to do this. I need to pass the two parameters to the function. Here is the code that i have written: -

<html>
<head>
</head>
<script language="javascript">

var password = "pass1";
var confirmPassword = "pass1";

function doFieldsMatch( password, confirmPassword)

{

if (password == confirmPassword) {
alert('Same Values')
return true;
}
else {
alert( 'Do not match');
return false;
}

}

</script>

<body>
<form id=myForm name=myForm action="/forum/someform.html" method="post">

<input type=submit value="Submit" onClick="doFieldsMatch('password', 'confirmPassword')">
</form>
</body>
</form>

Whatever values I set the variables to, the 'Do not match' option is always displayed.

Does anyone know what I am doing wrong?

All suggestions will be welcome.

  Re: Functions  Troy Wolf at 22:13 on Wednesday, March 03, 2004
 

I copied your code exactly into a new HTML file. I opened it in my browser, clicked the submit button, and got the message "Do not match".

I then changed the call to the function to pass the same value for both parameters. Then I reloaded the page and pressed the submit button. I got the message "Same Values".

Your code appears to work to me. I do see one simple mistake. The last tag should be "</html>". Instead, you have a second "</form>".
Troy Wolf: site expert
Shiny Solutions









CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  Testing file for type of data
•  Running VB6 application as a ASP.NET application
•  login system with asp.net
•  Re: Help: Trouble with z-Index and SELECT lists
•  What is wrong with this ASP codes? It don`t seem to work???
•  Need help with ListBox control
•  Re: Good Javascript/DHTML Reference
•  Re: scrolling table
•  Re: simulation of road traffic


Recent Articles
Communicating with the Database (Using ADO)
MagicGrid
Simple Thumbnail Browsing Solution
Type Anywhere
A Better Moustrap: FmtDate to replace FormatDateTime
ASP.NET Forum Source Code
Internal Search Engine
Javascript Growing Window
Simple date validation
Search engine friendly URLs using ASP.NET (C#.NET)


Site Survey
Help us serve you better. Take a five minute survey. Click here!

© Copyright codetoad.com 2001-2004