hi to all! I know it is quiet simple question but I am only a newbie. I made a php code using dreamweber for registration of new user. My problem now is I call the javascript function in "onclick" as my reset button but it doesn't work. It was run with the browser but If I click the reset it will proceed to the "action = register.php" instead of clearing the fields. Please help me
Please see the code
Thanks in advance
Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript">
function SubmitForm()
{
var form = document.forms[0];
var vRequired = true;
if ((form.UserName.value.length < 1) ||
(form.EmailAds.value.length < 1) ||
(form.ConfirmEmail.value.length < 1)
)
{
alert ("Please fill up all the fields.");
vRequired = false;
}
if (!vRequired) return flase;
form.submit();
}
function ResetForm()
{
var form = document.forms[0];
form.UseName.value = "";
form.EmailAds.value = "";
form.ConfirmEmail.value = "";
}
</script>
</head>
<body>
<div align="left">
<form id="frmRegister" name="frmRegister" method="post" action="register.php">
<div align="left">
<table width="400" border="0" cellspacing="1" cellpadding="1">
<tr>
<td colspan="4"><b>Registration Form</b></td>
</tr>
<td> </td>
<tr height="20">
<td height="26"><div align="left">User Name:</div></td>
<td height="26" align="left"><input type="text" name="UserName" id="UserName" value="<?php echo $_SESSION['UserName'] ?>" /></td>
</tr>
<tr>
<td height="26"><div align="left">E-mail Address:</div></td>
<td height="26" align="left"><input type="text" name="EmailAds" id="EmailAds" value="<?php echo $_SESSION['EmailAds']?>"/></td>
</tr>
<tr>
<td height="26"><div align="left">Confirm E-mail Address:</div></td>
<td height="26"><input type="text" name="ConfirmEmail" id="ConfirmEmail" value="<?php echo $_SESSION['ConfirmEmail']?>"/> </td>
</tr>
<tr>
<td height="26"><div align="left">Password:</div></td>
<td height="26"><input type="password" name="Password" id="Password" value="<?php echo $_SESSION['Password']?>"/> </td>
</tr>
<tr>
<td height="26"><div align="left">Confirm Password:</div></td>
<td height="26"><input type="password" name="ConfirmPassword" id="ConfirmPassword" value="<?php echo $_SESSION['ConfirmPassword']?>"/> </td>
</tr>
<tr>
<td height="26">
<td height="26"><input type="submit" name="reset" id="reset" value="Reset" onclick= "ResetForm();" />
<input type="submit" name="submit" id="submit" value="Submit" onclick="SubmitForm(); Return False;" /></td>
</tr>
</table>
</div>
</form>
</div>
</body>
</html>