from表单

来源:互联网 发布:网络经典小说排行榜 编辑:程序博客网 时间:2024/05/17 02:08
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
</head>

<body>


<form action="" method="post" onsubmit="return checkForm()">
    <input type="text" name="username" id="name">
    <input type="text" name="password" id="password">
    <input type="submit" value="提交">
</form>
<script>
    function checkForm(){
        var name=document.getElementById("name").value;
        if(name==""||name==null){
            return false;
        }
        var pwd=document.getElementById("password").value;
        if(pwd==""||pwd==null){
            return false;
        }
        return true;
    }
</script>
</body>

</html>

转载:http://blog.csdn.net/s_liuxin_s/article/details/51011821