拷贝下面的代码到你的html文件的<head>和</head>之间;
<script language="JavaScript">
<!--
function validate_form() {
validity = true;
if (!check_empty(document.form.NAME.value))
{ validity = false; alert('没有填写姓名!'); }
if (!check_email(document.form.EMAIL.value))
{ validity = false; alert('Email地址错误!'); }
if (!check_url(document.form.URL.value))
{ validity = false; alert('主页网址错误!'); }
if (!check_empty(document.form.DESCRIPTION.value))
{ validity = false; alert('缺少内容简介!'); }
if (validity)
alert ("Needed entries have been verified. "
+ "Your form is now being passed to your browser's "
+ "Mail Delivery Sub-System.");
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;
}
function check_url(address) {
if ((address == "")
|| (address.indexOf ('http://') == -1)
|| (address.indexOf ('.') == -1))
return false;
return true;
}
// -->
</script>
拷贝下面的代码到你的html文件的<body>和</body>之间;
<form name="form" method="post"
action="mailto:alone@188.net?SUBJECT=友情连接" enctype="text/plain"
onSubmit="return validate_form()">
<p>姓名:<br>
<input type="text" size="40" name="NAME"><br>
Email地址:<br>
<input type="text" size="40" name="EMAIL"><br>
主页网址:<br>
<input type="text" size="40" name="URL"
value="http://"><br>
内容简介:<br>
<textarea NAME="DESCRIPTION" ROWS="5" COLS="40"
wrap="virtual"></textarea><br>
<input type="submit" name="submit" value="立刻发送">
<input type="reset"
value="重新填写"> </p>
</form>
说明:这个表单会检测姓名是否为空,email是否含"@"".",网址是否含"http"".",内容是否为空。是很有实用性的表单程序。将其中的mailto:的email地址修改成你自己的就可以用了。
|