hello_world_
2015-02-04 22:02
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>测试验证</title>
<link href="css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<form id="form">
<div class="form-group has-feedback id=""form1">
姓名:<input type="text" id="input1" placeholder="请输入姓名" >
<span id="s1" style="display:none">你输入的信息是正确的</span>
<span id="ss1" class="glyphicon glyphicon-ok form-control-feedback" style="display:none"></span>
<span id="w1" style="display:none">请输入正确信息</span>
<span id="ww1" class="glyphicon glyphicon-warning-sign form-control-feedback" style="display:none"></span>
<span id="e1" style="display:none">验证不通过</span>
<span id="ee1" class="glyphicon glyphicon-remove form-control-feedback" style="display:none"></span>
</div>
<div class="form-group has-feedback"
id="form2">
学号:<input type="text" id="input2" placeholder="请输入学号" >
<span style="display:none">你输入的信息是正确的</span>
<span class="glyphicon glyphicon-ok form-control-feedback" style="display:none"></span>
<span style="display:none">请输入正确信息</span>
<span class="glyphicon glyphicon-warning-sign form-control-feedback" style="display:none"></span>
<span style="display:none">验证不通过</span>
<span class="glyphicon glyphicon-remove form-control-feedback" style="display:none"></span>
</div>
<button type="submit" class="btn btn-primary" id="submit">提交</button>
</form>
<script src="http://cdn.bootcss.com/jquery/1.11.2/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script>
$("#submit").click(function(){
if($("#input1").val()==null)
{
$("#form1").addClase("has-warning");
$("#w1").show();
$("#ww1").show();
}
});
</script>
</body>
</html>
这样子写实现不了,<script></script>里是不是有问题
你把null改成0试试
你的addClass 也是拼错了。。。
你把null和“”都去掉。换成if(!$("#input1").val()){ ...
}
他会把你判断的无值,未定义等判为false
玩转Bootstrap(基础)
314546 学习 · 2275 问题
相似问题