表单验证

Posted bianzhuo

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了表单验证相关的知识,希望对你有一定的参考价值。

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<form id =‘f1‘ action="https://www.baidu.com" method="get">
    <div><input name="n1" type="text"></div>
    <div><input name="n2" type="password"></div>
    <div><input name="n3" type="text"></div>
    <div><input name="n4" type="text"></div>
    <div><input name="n5" type="text"></div>
    <input type="submit" value="提交">
</form>
<script src="jquery1.9.js"></script>
<script>
    $(:submit).click(function () {

        $(#f1).find(input[type="text"],input[type="password"]).each(function () {
            var v=$(this).val();
            console.log(1)
            if(v.length<=0){
                return false;
            }
        });
        console.log("haha");
        return false;
    });
</script>
</body>
</html>

 

    

以上是关于表单验证的主要内容,如果未能解决你的问题,请参考以下文章