hi all,
i wanted to check whether the password entered matches with the confirm password.either through javascript or through php.i have enclosed my code somebody help on this
i wanted to check whether the password entered matches with the confirm password.either through javascript or through php.i have enclosed my code somebody help on this
Code:
<html>
<?include 'menu.php'?>
<head>
<script type="text/javascript">
function checkform()
{
var cfname,cstatus,cuname,cpwd,cconfirmpwd;
with(window.document.createuserform)
{
cfname=fname;
cstatus=status;
cuname=uname;
cpwd=pwd;
cconfirmpwd=confirmpwd;
}
if(trim(cfname.value)=="")
{
alert("please enter the first name");
cfname.focus();
return false;
}
else if(trim(cstatus.value)=="")
{
alert("please enter the status");
cstatus.focus();
return false;
}
else if(trim(cuname.value)=="")
{
alert("please enter the user name");
cuname.focus();
return false;
}
else if(trim(cpwd.value)=="")
{
alert("please enter the password");
cpwd.focus();
return false;
}
else if(trim(cconfirmpwd.value)=="")
{
alert("confirm the password");
cconfirmpwd.focus();
return false;
}
else
{
cfname.value=trim(cfname.value);
cstatus.value=trim(cstatus.value);
cuname.value=trim(cuname.value);
cpwd.value=trim(cpwd.value);
cconfirmpwd.value=trim(cconfirmpwd.value);
}
function trim(str)
{
return str.replace(/^\s+|\s+$/g,'');
}
}
</script>
Code:
</head> <center><h3>CREATE USER</h3></center> <body> <form name="createuserform" action="insertuser.php" method="POST" onsubmit="return checkform()"> <table> <td> <table border="0" cellpadding="0" cellspacing="0"> <tr> <td> <table border="0" cellpadding="0" cellspacing="0"> <tr> <td style="padding-left:20px;padding-bottom:20px;"><a href="createuser.php" style="text-decoration:none"><input type="button" name="new" value="CREATE USER" style="width:170px;background-image:url(pink.gif)"></a></td> </tr> <tr> <td style="padding-left:20px;padding-bottom:20px;"><a href="users.php" style="text-decoration:none"><input type="button" name="new" value="USERS" style="width:170px;background-image:url(pink.gif)"></a></td> </tr> <tr> <td style="padding-left:20px;"><a href="reassignrecords.php" style="text-decoration:none"> <input type="button" name="new" value="REASSIGN RECORDS" style="width:170px;background-image:url(pink.gif)"></a></td> </tr> </table> </td> <td> <TABLE cellpadding="5" cellspacing="6" align="center" with frame="box"> <tr> <th>First Name<font color="red">*</font></th> <td><input type="text" name="fname"> <th>Last Name</th> <td><input type="text" name="lname"> <th>Status</th> <td><select name="status"> <option>Active</option> <option>Inactive</option> </select> </td> </tr> <tr> <th>User Name<font color="red">*</font></th> <td><input type="text" name="uname"> <th>Password<font color="red">*</font></th> <td><input type="password" name="pwd" > <th>Confirm Password<font color="red">*</font></th> <td><input type="password" name="confirmpwd"> </tr> <tr> <th>Title</th> <td><input type="text" name="title"> <th>Department</th> <td><input type="password" name="dept" > <th>Phone</th> <td><input type="password" name="phone"> </tr> <tr> <th>Address</th> <td><input type="text" name="address"> <th>City</th> <td><input type="password" name="city" > <th>Pincode</th> <td><input type="password" name="pin"> </tr> </table> </td> </table> <br/> <br/> <center> <input type="submit" value="SAVE" style= "width:110px; height:31px; background-image: url(pink.gif)"> <input type="button" value="CANCEL" style= "width:110px; height:31px; background-image: url(pink.gif)"></a> </center> </form> </body> </html>
Comment