验证数据是否为空

<script type="text/javascript">
        function xuanzhe()
        {
            var User = document.getElementById('Txt_User').value;
            var Pwd = document.getElementById('Txt_Pwd').value;
            if (User.length == 0)
            {
                window.alert('请输入用户名!');
                event.returnValue = false; //取消数据提交
            } else if (Pwd.length == 0)
            {
                window.alert('请输入密码!');
                event.returnValue = false; //取消数据提交
            }
        }
    </script>

 

posted @ 2015-12-15 16:35  时代码农  阅读(218)  评论(0编辑  收藏  举报