✔ 最佳答案
Is this what you want?
Please replace all the " with a double-quote. (") It's just an display error...
You'd also have to replace <form action="xxxx"> to point to wherever your form data needs to be sent to.
<html >
<head >
<script >
function clearUp(){
document.getElementById("date").value = "";
document.getElementById("pickup").value = "";
document.getElementById("destination").value = "";
document.getElementById("name").value = "";
document.getElementById("address").value = "";
document.getElementById("phone").value = "";
}
function verify(){
var message = "";
if (document.getElementById("date").value == "")
{
message += "Date/Period Required\n";
}
if(document.getElementById("pickup").value == "")
{
message += "Pick-Up Point\n";
}
if(document.getElementById("destination").value == "")
{
message += "Destination Point\n";
}
if(document.getElementById("name").value == "")
{
message += "Name\n";
}
if(document.getElementById("address").value == "")
{
message += "Address\n";
}
if(document.getElementById("phone").value == "")
{
message += "Phone\n";
}
if (message != "")
{
alert("The following required fields are missing:\n" + message);
return false;
}
alert("Order Submitted");
return true;
}
</script >
</head >
<body >
<form action="confirm.html" onsubmit="return verify();" />
Date/Period Required:
<br />
<input type="text" id="date" />
<br />
<br />
Pick-Up Point:
<br />
<input type="text" id="pickup" />
<br />
<br />
Destination Point:
<br />
<input type="text" id="destination" />
<br />
<br />
Name:
<br />
<input type="text" id="name" />
<br />
<br />
Address:
<br />
<input type="text" id="address" />
<br />
<br />
Phone:
<br />
<input type="text" id="phone" />
<br />
<br />
<input type="button" value="ClearUp" onClick="clearUp();" />
<input type="submit" value="Submit" />
</form >
</body >
</html >