<html>
<head>
<title> 谊线牵网络 </title><script language="javascript1.5">
function validate(f) {
var value = f.email.value;
if(!/^\w + @\w + .\w + $/.test(value)) {
alert("email输入格式错误");
f.email.focus();
f.email.select();
return false;
}
return true;
}
</script>
</head>
<body>
<form action ="" method = "post" name = "myform" onsubmit="return validate(this)">
EMAIL: <input type = "text" name = " email">
<input type="submit" value="提交">
</form>
</body>
</html>
刚学的小小菜鸟
请问下为什么无论我在生成的页面输入什么内容。都不执行alert语句啊。谢谢。
在ie和火狐都一样
activex的控件之类都启用了啊
<head>
<title> 谊线牵网络 </title><script language="javascript">
function validate(f) {
var value = f.email.value;
if(!/^\w + @\w + .\w + $/.test(value)) {
alert("email输入格式错误");
f.email.focus();
f.email.select();
return false;
}
return true;
}
</script>
</head>
<body>
<form action ="" method = "post" name = "myform" onsubmit="return validate(this)">
EMAIL: <input type = "text" name = "email">
<input type="submit" value="提交">
</form>
</body>
</html>
function validate(f) {
var value = f.email.value;
if(!/^\w + @\w + .\w + $/.test(value)) {
alert("email输入格式错误");
f.email.focus();
f.email.select();
return false;
}
return true;
}
</script>language
language 改成了javascript了。 是这两个地方吗。
可以执行了。另外弱弱的问下 为什么我贴的代码为什么没有关键字高亮。。
应该这样吧
<head>
<title> 谊线牵网络 </title><script language="javascript">
function validate(f) {
var value = f.email.value;
if(!/^\w+@\w+.\w+$/.test(value)) {
alert("email输入格式错误");
f.email.focus();
f.email.select();
return false;
}
return true;
}
</script>
</head>
<body>
<form action ="" method = "post" name = "myform" onsubmit="return validate(this)">
EMAIL: <input type = "text" name = "email">
<input type="submit" value="提交">
</form>
</body>
</html>
or
language="javascript"