<script Language="JavaScript">
function evalform(address)
{
var crucial,message;
crucial=address.indexOf("@");
if (crucial==-1)
{
window.alert("Error!");
return false;
}else{
message="OK!";
return window.confirm(message);
}
}
</script>表单如下:
<form onSubmit="JavaScript:evalform(this.email.value);" >
<input name="email" type="text">
<input name="yes" type="submit" value="确定" >
<input type="reset" name="ok" value="重置">
</form>
function evalform(address)
{
var crucial,message;
crucial=address.indexOf("@");
if (crucial==-1)
{
window.alert("Error!");
return false;
}else{
message="OK!";
return window.confirm(message);
}
}
</script>表单如下:
<form onSubmit="JavaScript:evalform(this.email.value);" >
<input name="email" type="text">
<input name="yes" type="submit" value="确定" >
<input type="reset" name="ok" value="重置">
</form>
2、if结构不需要Then
3、if后面的表达式要用括号括起来
4、onSubmit最好写成这样"JavaScript:evalform(this.email.value);"
1:Function 中F不能为大写,应该为:function
2: if语句错误,if后面应该是括号,不能有then,这是VBS才用then
以下是正确代码!
<script Language="JavaScript">
<!--
function evalform(address)
{
var crucial,message;
crucial=address.indexOf("@");
if(crucial==-1)
{
window.alert("Error!");
return false;
}
else
{
message="OK!";
return window.confirm(message);
}
}//-->
</script>表单如下:
<form onSubmit="evalform(this.email.value)" >
<input name="email" type="text">
<input name="yes" type="submit" value="确定" >
<input type="reset" name="ok" value="重置">
</form>
<!--
function evalform(address)
{
var crucial,message;
crucial=address.indexOf("@");
if (crucial==-1)
{ window.alert("Error!");
return false;
}
else
{
message="OK!";
return window.confirm(message);
}
}//-->
</script>表单如下:
<form onSubmit="return evalform(this.email.value)" >
<input name="email" type="text">
<input name="yes" type="submit" value="确定" >
<input type="reset" name="ok" value="重置">
</form>