码迷,mamicode.com
首页 > 编程语言 > 详细

python :表单验证--对每一个输入框进行验证

时间:2016-12-08 23:56:02      阅读:374      评论:0      收藏:0      [点我收藏+]

标签:name   jquer   var   orm   tle   method   return   pos   length   

技术分享
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta charset="UTF-8"/>
    <title>Title</title>
    <style>
        .error{
            color: red;
        }
    </style>
</head>
<body>
<form id="ff" method="post">
    <div><input type="text"/></div>
    <div><input type="password"/></div>
    <div><input type="text"/></div>
    <div><input type="text"/></div>
    <div><input type="text"/></div>
    <div><input type="submit" value="提交"/></div>
</form>
<script src="jquery-1.12.4.js"></script>
<script>
    $(:submit).click(function () {
        $(.error).remove()
        var flag = true;
         $(#ff).find(input[type="text"],input[type="password"]).each(function () {

            var tag = $(this).val();
            if (tag.length <= 0) {
                flag = false;
                var  v= document.createElement(span);
                v.innerHTML = 必填;
                v.className=error;
                $(this).after(v)
                 return false
//                只提示第一个 return false
            }
        })
        return flag;

    })
</script>
</body>
</html>
提交表单验证

 

python :表单验证--对每一个输入框进行验证

标签:name   jquer   var   orm   tle   method   return   pos   length   

原文地址:http://www.cnblogs.com/xuehuahongmei/p/6146857.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!