input是否为空

来源:互联网 发布:ipad 电子相册软件 编辑:程序博客网 时间:2024/05/29 17:32
<!DOCTYPE html><html><head lang="en">    <meta charset="UTF-8">    <title>判断是否为空</title>    <script language="javascript">        function testnull()        {            if (document.getElementById('airline').value=='')            {                alert('输入不能为空');                document.getElementById('airline').focus();            }        }    </script></head><body>输入框:<input type="text" name="airline" id="airline" style="width: 200px;" placeholder="输入不用为空"><br><input type="button" onclick="testnull()" value="记录"style="background-color: blueviolet"/><br><br></body></html>