版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
<body>
<p>
<input type="text" id="username"/>
</p>
<p>
<input type="password" id="password"/>
</p>
<p>
<button id="btn" type="button">提交</button>
</p>
<script>
$('#btn').click(function(){
if($('#username').val().length==0){
alert('输入不能为空')
}else if($('#password').val().length<6){
alert('长度不可以少于6位')
}
})
</script>
</body>