//the code
[HTML]<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>TEST form</title>
<script type="text/javascript">
function check()
{
txt1= document.getEle mentById("usern ame")
txt2= document.getEle mentById("passw ord")
if(document.get ElementById("us ername").value= ="")
{
alert(document. getElementById( "username").nam e);
}
if(document.get ElementById("pa ssword").value= ="")
{
alert(document. getElementById( "password").nam e);
}
return true
}
</script>
</head>
<body>
<div align="right">
<form id="form1" name="form1" method="post" action="test-2.php" onsubmit="retur n check()">
<label> Username:
<input type="text" name="username" id="textfield" />
<br />
Password:
<input type="text" name="password" id="textfield2 " />
<br />
<input type="submit" name="Login" id="Login" value="Submit" />
</label>
</form>
</div>
</body>
</html>[/HTML]
in this code i need to disable the form to Submit the data to another page and how to simplify the code without using if statement many times
[HTML]<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>TEST form</title>
<script type="text/javascript">
function check()
{
txt1= document.getEle mentById("usern ame")
txt2= document.getEle mentById("passw ord")
if(document.get ElementById("us ername").value= ="")
{
alert(document. getElementById( "username").nam e);
}
if(document.get ElementById("pa ssword").value= ="")
{
alert(document. getElementById( "password").nam e);
}
return true
}
</script>
</head>
<body>
<div align="right">
<form id="form1" name="form1" method="post" action="test-2.php" onsubmit="retur n check()">
<label> Username:
<input type="text" name="username" id="textfield" />
<br />
Password:
<input type="text" name="password" id="textfield2 " />
<br />
<input type="submit" name="Login" id="Login" value="Submit" />
</label>
</form>
</div>
</body>
</html>[/HTML]
in this code i need to disable the form to Submit the data to another page and how to simplify the code without using if statement many times
Comment