<!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>Save new student</title>
<script>
function insertdata()
{
var n = document.getElementById("name").value;
var f = document.getElementById("family").value;
var m = document.getElementById("mark").value;
var t = document.getElementById("tell").value;
if ((n=="") || (f=="") || (m=="") || (t=="")){
var error=document.getElementById("error").innerHTML="fill out the form with valid values";
}
**else if()**
{
}
else{
frminsert.submit();
}
}
</script>
</head>
<body>
please enter your data:
<br/>
<form action="saveinsert.php" method="post" name="frminsert">
Name :
<input type="text" name="name" id="name" />
<br/>
Family :
<input type="text" name="family" id="family" />
<br/>
Mark :
<input type="text" name="mark" id="mark" />
<br/>
Tell :
<input type="text" name="tell" id="tell" />
<br />
<input type="button" value="Save New Student" onclick="insertdata();" />
<input type="reset" value="Reset Form" />
</form>
<p id="error"></p>
<a href="show.php">show the list of students</a>
</body>
</html>
我的代码将使用此语句指示错误消息:正确填写表格。
我将详细说明它,当用户开始在键盘上键入时,我需要消除上面提到的错误消息。