今天搞了一天也没能解决,哪位大佬能帮忙看看,点了提交按钮只会跳到这个代码的页面,在别人电脑上都是可以有用的,以下是原代码
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
</head>
<style>
*{
margin: 0;
padding: 0;
}
td{
border: #000000 solid 1px;
line-height: 40px;
text-align: center;
}
.dv{
margin: 0 auto;width:500px;
}
.inputs{
height: 30px;
line-height: 30px;
border: #C45E60 solid 1px;
}
inputs #btn{
height: 40px;
line-height: 40px;
background-color: aqua;
color: blue;
}
</style>
<script src="jquery-1.12.2.min.js"></script>
<script>
/eck检查部分,一般开说不会出现在当前页面,一般servlet页
function check(){
//任务需求:对email部分进行检查,第一用户不能输入空(空值可以用一串零进行替代),第二邮箱要包含@,.
var email=$("#email").val()//text()获得p里面的值,val()表单里面对应的值,attr()获得整个html,prop().都是用来获取表单的值
if(email==""){
alert("不可以为空");
return false;

}
if(email.indexOf("@")==-1 || email.indexOf(".")==-1){//indexOf是用来判断是否半酣某个值,如果为-1则不包含
alert("必须包含@或.");
return false;
}
/*if(email.indexOf(".")==-1){//indexOf是用来判断是否半酣某个值,如果为-1则不包含
alert("必须包含.");
return false;
}*/
return true;
}
//调用检查实现效果的过程
$(document).ready(function(){
$("#myform").submit(function(){
return check();
});
});
</script>
<body>
<div class="dv">
<form action="选择器.html" method="post" id="myform" name="myform">
<table width="500px" border="0px">
<tr>
<td colspan="2">某某网登录</td>
</tr>
<tr>
<td>Email</td>
<td><input type="text" id="email" class="inputs"></td>
</tr>
<tr>
<td>密码</td>
<td><input type="password" id="pwd" class="inputs"></td>
</tr>
<tr>
<td colspan="2"><input type="submit" class="btn" name="btn" value="提交"></td>
</tr>
</table>
</form>
</div>
</body>
</html>