actually i want to compare pass1.value with pass2.value...dis is my code please check it..

<html>
<head>

<script type="text/javascrpit">

function myFunction()
{
alert " pass1.value";
var x=document.getElementById("pass1").value;
var y=document.getElementById("pass2").value;
if(x == y)
{
alert "password matches";
}
else
{
alert "password dosn't matches";
}
}

</script>
</head>
<form name="mailform" method="POST" action="#">
<table>
<tr>
<td>Password:<sup style="color: red;"></sup></td>
<td><input name="pass1" id="pass1" type="password"></td>
</tr>
<tr>
<td>Re-Type Password:<sup style="color: red;"></sup></td>
<td><input name="pass2" id="pass2" type="password"></td>
</tr>
</table>
<input type="submit" value="submit" onsubmit="myFunction()">
</form>
<div id="abc" style="display:none; color:#FF0000;">
<table>
<tr>
<td id="one">
</td>
</tr>
</table>
</div>
</html>

Recommended Answers

All 2 Replies

Fix the typo in line 4.

<body> tag is missing too.

The brackets are missing after the "alert" command.
The line numbers 8, 13 and 17 should be corrected.
8. alert " pass1.value";
13. alert "password matches";
17. alert "password dosn't matches";

The above lines of code should be corrected as below

8.  alert(pass1.value);
13. alert("password matches");
17. alert("password dosn't matches");
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.