日期:2014-05-16  浏览次数:20391 次

求解javascript,
<html>
<head><title>民航管理系统</title>
<style>
#dengru{ 
position:absolute; 
top:50%; 
left:50%; 
margin:-150px 0 0 -150px; 
width:300px; 
height:300px; 
border:1px ; 


</style>
</head>
<body>
<div id="dengru" align="center">
<form name="form1" action="#" onSubmit="return check()">
<p><font size="4">用户名:</font><input type="text" name="user"></p>
<p><font size="4">密 &nbsp;&nbsp;码:</font><input type="password" name="password"></p>
<p><input type="submit" name="button" value="登入" style="font-size=16;height=25px;width=50px;">&nbsp;&nbsp;&nbsp;
<input type="button" value="退出" style="font-size=16;height=25px;width=50px;" onclick="alert('哈哈哈哈')">&nbsp;&nbsp;&nbsp;
<input type="button" value="游客" style="font-size=16;height=25px;width=50px;"> <br></p>
</form>
</div>
</body>
</html>
<script language="javascript">
<!--
function check(){
if(document.form1.user.value.length==0){
alert("f");
renturn false;
}
if(document.form1.password.value.length==0){
alert("f");
return false;
}
return true;
}
-->
</script>

按理说这样编辑没有什么错误,可是在<form name="form1" action="#" onSubmit="return check()">这里提示
Cannot return from outside a function or method;
而且在<script language="javascript">提示NLS missing message: Obsolete_attribute_name___ERROR_ in: 
 org.eclipse.wst.html.core.internal.HTMLCorePluginResources
求救啊,在线等候,我用的是myeclipse 10

------解决方案--------------------
<form name="form1" action="#" onSubmit="check()">//提示很清楚,不能在函数外面执行return,把return去掉就可以了

document.form1.user.value.length
document.form1.password.value.length
这两个是什么东西,有这种写法??
改一下:
if(document.getElementsByName('user')[0].value.length==0)
下面一个也这样改
------解决方案--------------------
HTML code

<script language="javascript">  //首先这里最好改为<script type="text/javascript">  //<script language="javascript"> 是较早的用法
<!--
function check(){
if(document.form1.user.value.length==0){
alert("f");
renturn false;  //这个地方写错了 return false;
}
if(document.form1.password.value.length==0){
alert("f");
return false;
}
return true;
}
-->
</script>

------解决方案--------------------
onsubmit里面写return就是会报警告的,但没关系,可以正常执行。把return删了就失效了。
------解决方案--------------------
貌似必须有return吧 要不就直接提交了