form表单提交不成功提示

<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <meta charset="utf-8">
        <title>Form 校验</title>
        <script>
            function CheckForm(form) {
                if(form.username.value == "") {
                    alert('名字总要填一个吧!');
                    form.username.focus();
                    return false
                }
            return true;
            }
        </script>
    </head>
    <body>
        <form name="form1" id="form1" action="" method="post" onsubmit="CheckForm(this)">
            <input type="text" name="username">
            <input type="submit" value=" 提交">
        </form>
    </body>
</html>

 

posted @ 2015-11-23 16:35  星辰之力  阅读(1648)  评论(0编辑  收藏  举报