hvkhanh90
19-06-2011, 12:05 AM
ko biết sai ở đâu mà ko chạy đc :(
file .html đính kèm ở dưới !
<html>
<head>
<title> Ho van khanh</title>
<script language="javascript">
<!--
function validateFirstName()
{
var str= form1.1name.value;
if(str.length==0)
{
alert("the first name cannot be empty");
return false;
}
return true;
}
function validateLastName()
{
var str=form1.2name.value;
if(str.length==0)
{
alert("the last name cannot be empty");
return false;
}
return true;
}
function validateEmail()
{
var str=form1.email.value;
{
if(str.length==0)
alert("email cannot be empty");
return false;
}
return true;
}
function processform()
{
disp=open(" ", "result")
disp.document.write("<title>Result page</title> "+" <pre>")
disp.document.write("<h2 align='center'> "+"Thanks for signing in "+" </h2> "+" <hr> "+" <br><br>")
disp.document.write("first name \t\t: "+form1.1name.value+" <br>")
disp.document.write("last name \t\t: "+form1.2name.value+" <br>")
disp.document.write("email \t\t: "+form1.email.value+" <br>")
disp.document.write("your comments \t\t: "+form1.comment.value+" <br>")
disp.document.write("<pre>")
if(disp.confirm("is this information correct"))
disp.close()
}
//-->
</script>
</head>
<body>
<h1 align=center>Handing Form Events</h1><hr>
<form name="form1">
<p>First name: <input type="text" name="1name" size="10" onBlur="validateFirstName()"></p>
<p>Last name: <input type="text" name="2name" size="15" onBlur="validateLastName()"></p>
<p>Email: <input type="text" name="email" size="10" onBlur="validateEmail()"></p>
<p>Comments: <textarea name="comment" rows=4 cols=20>Enter your comments here</textarea></p>
<input type="submit" value="submit this form" onClick="processform()">
<input type="reset" value="reset">
</form>
</body>
</html>
file .html đính kèm ở dưới !
<html>
<head>
<title> Ho van khanh</title>
<script language="javascript">
<!--
function validateFirstName()
{
var str= form1.1name.value;
if(str.length==0)
{
alert("the first name cannot be empty");
return false;
}
return true;
}
function validateLastName()
{
var str=form1.2name.value;
if(str.length==0)
{
alert("the last name cannot be empty");
return false;
}
return true;
}
function validateEmail()
{
var str=form1.email.value;
{
if(str.length==0)
alert("email cannot be empty");
return false;
}
return true;
}
function processform()
{
disp=open(" ", "result")
disp.document.write("<title>Result page</title> "+" <pre>")
disp.document.write("<h2 align='center'> "+"Thanks for signing in "+" </h2> "+" <hr> "+" <br><br>")
disp.document.write("first name \t\t: "+form1.1name.value+" <br>")
disp.document.write("last name \t\t: "+form1.2name.value+" <br>")
disp.document.write("email \t\t: "+form1.email.value+" <br>")
disp.document.write("your comments \t\t: "+form1.comment.value+" <br>")
disp.document.write("<pre>")
if(disp.confirm("is this information correct"))
disp.close()
}
//-->
</script>
</head>
<body>
<h1 align=center>Handing Form Events</h1><hr>
<form name="form1">
<p>First name: <input type="text" name="1name" size="10" onBlur="validateFirstName()"></p>
<p>Last name: <input type="text" name="2name" size="15" onBlur="validateLastName()"></p>
<p>Email: <input type="text" name="email" size="10" onBlur="validateEmail()"></p>
<p>Comments: <textarea name="comment" rows=4 cols=20>Enter your comments here</textarea></p>
<input type="submit" value="submit this form" onClick="processform()">
<input type="reset" value="reset">
</form>
</body>
</html>