0

what is wrong in the below code?
i am not able to write in div er

function check()
{
	
	var pass,confirm;
	pa=document.chg_pwd.pass.value;
	confir=document.chg_pwd.confirm.value;
	
	if(pa!=confir)
	{
		return true;
		}
	else
	{
		return false;
		}
}
function val()
		{
	var pass=document.chg_pwd.old.value;
	
	if(pass==="" || pass==null )
	{
		return false;
		}
	else
	{
		return true;
	}
		}	
function validate()

{
		if(val())
		{
			document.getElementById("Er").innerHTML="Required field cannot be empty";
		}
		if(check())
		{
			document.getElementById("Err").innerHTML="Passwords do not match";
		}
}
<form name="chg_pwd" method="post">
<table width="614" height="242" border="1">
        <tr>
          <td colspan="3" align="center" valign="middle"><span class="style3">Change Password </span></td>
          </tr>
        <tr>
          <td width="151">Enter current password: </td>
          <td><input type="text" name="old"></td>
          <td><div id="Er"></div></td>
        </tr>
        <tr>
          <td>Enter new password: </td>
          <td colspan="2"><input type="password" name="pass"></td>
        </tr>
        <tr>
          <td>Re-type password: </td>
          <td width="157"><input type="password" name="confirm"></td>
          <td width="284"><div id="Err">&nbsp;</div></td>
        </tr>
        <tr>
          <td colspan="3" align="center" valign="middle"><input type="button" name="Submit" value="Update" onClick="validate()"></td>
          </tr>
      </table>
</form>
2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by shiv0013
0

>> Line 4 and 6 - you declare the variable's name as confirm , but you use the the variable name confir in the script.

>> Line 21 - === needs to be == ~G

Edited by Graphix: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.