用mailto发邮件,想先验证一下填写的内容,然后再发,验证不过,就不要发了。
这是我的代码
<!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=iso-8859-1" />
<title>Untitled Document</title>
</head>
<Script language="javascript">
function validate_form() {
validity = true;
if (!check_empty(document.form.name.value))
{ validity = false; alert('Sorry!Please Fill in your name'); }
if (!check_email(document.form.email.value))
{ validity = false; alert('Sorry!Please Fill in the correct Email address'); }
if (!check_empty(document.form.company.value))
{ validity = false; alert('Sorry!Please Fill in your company'); }
if (validity)
alert (" Thanks for your register, "
+ " we will inform you soon ");
return validity;
}
function check_empty(text) {
return (text.length > 0);
}
function check_email(address) {
if ((address == "")
|| (address.indexOf ('@') == -1)
|| (address.indexOf ('.') == -1))
return false;
return true;
}
</Script>>
<body>
<form name="form" action="" method="post" action=" mailto:duji0002@ntu.edu.sg?subject=Register Training" enctype="text/plain">
<p align="center"><font size="3"><b><font size="4" face="Verdana, Arial, Helvetica, sans-serif">Name</font>:</b></font>
<input name="name" type="text" id="name" size=46>
<br>
<b><font size="4" face="Verdana, Arial, Helvetica, sans-serif">Email</font><font size="4"></font><font size="3">: </font></b>
<input name="email" type="text" id="email" size=46>
<br>
<b><font size="4" face="Verdana, Arial, Helvetica, sans-serif">Company</font><font size="4"></font><font size="3">: </font></b>
<input name="company" type="text" id="company" size=46>
<br>
<b><font size="4" face="Verdana, Arial, Helvetica, sans-serif">Telephone</font><font size="4"></font><font size="3">: </font></b>
<input name="telephone" type="text" id="telephone" size=46>
<br>
<b><font size="4" face="Verdana, Arial, Helvetica, sans-serif">Comments</font><font size="4"></font><font size="3">:</font></b>
<br>
<textarea name="comments" rows=8 cols=45 wrap=virtual id="txt"></textarea>
</p>
</div> </td>
</tr>
<tr>
<td>
<div align="center">
<div align="center">
<br>
<input type="submit" name="submit" value="Send" onclick("validate