要求: 点击id为btn的按钮, 1.判断id为username的输入是否为空,如果为空,则弹出你输入的不能为空. 2.判断id为pass

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接: https://blog.csdn.net/weixin_45747808/article/details/102759847
<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>

猜你喜欢

转载自blog.csdn.net/weixin_45747808/article/details/102759847