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>

>> 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

thanks

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.