jQuery实现输入框功能

GIF动态图:html

 

 

 

 

代码:jquery

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/html">
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <script src="jquery-3.3.1.js"></script>
</head>
<body>
<div id="div09">
<p><input id="userName" type="text"></p>
<p><input id="password" type="password"></p>
<p><button type="button" id="btn">提交</button></p>
</div>
<script>

 $("#btn").on('click',function(){
           var name = $('[type=text]').val();
            var pwd = $('[type=password]').val();
            if(name.length==0){
                alert("你输入的不能为空")
            }
            if(pwd.length<6){
                alert("你输入的长度不能够少于6位")
            }

        });
</script>
</body>
</html>
相关文章
相关标签/搜索