Javascript代码
function jsCheck() {
var msg = '';
//Move email checker to first line of javascript validation
if (document.form1.email.value.indexOf(".") <= 3 && document.form1.email.value.indexOf("@") <= 2){ msg = msg + 'Valid Email Address\n'; }
if (document.form1.name.value == ""){ msg = msg + 'Full Name\n'; }
if (document.form1.company.value == ""){ msg = msg + 'Company Name\n'; }
if (document.form1.telephone.value == ""){ msg = msg + 'Telephone No\n'; }
if (document.form1.country.value == ""){ msg = msg + 'Country\n'; }
if (msg != ''){
alert('The following fields are missing\n\n' + msg);
return false;
}
form name="form1" method="post" action="apply_confirm.asp" onSubmit="return jsCheck();"
为什么没有调用javascript
答案 0 :(得分:5)
好吧,如果你的原始帖子是准确的(由于人们试图使你的帖子清晰可见,许多事情都发生了变化),这是因为你发布的所有内容都包含在HTML评论<!-- ... -->
中。
是的,就尽快提供解决方案而言,你可能要记住我们不适合你。
答案 1 :(得分:2)
您的javascript代码中很可能出错。
答案 2 :(得分:2)
试试这个:
<html>
<head>
<script type="text/javascript">
function jsCheck() {
var msg = '';
//Move email checker to first line of javascript validation
if (document.form1.email.value.indexOf(".") <= 3 && document.form1.email.value.indexOf("@") <= 2){ msg = msg + 'Valid Email Address\n'; }
if (document.form1.name.value == ""){ msg = msg + 'Full Name\n'; }
if (document.form1.company.value == ""){ msg = msg + 'Company Name\n'; }
if (document.form1.telephone.value == ""){ msg = msg + 'Telephone No\n'; }
if (document.form1.country.value == ""){ msg = msg + 'Country\n'; }
if (msg != ''){
alert('The following fields are missing\n\n' + msg);
return false;
}
return true;
}
</script>
</head>
<body>
<form name="form1" method="post" action="apply_confirm.asp" onSubmit="return jsCheck();">
<input type='text' id='name'/>
<input type='text' id='company'/>
<input type='text' id='email'/>
<input type='text' id='telephone'/>
<input type='text' id='country'/>
<input type='submit' value='submit'/>
</form>
</body>
</html>
答案 3 :(得分:0)