zoukankan      html  css  js  c++  java
  • jquery validate

    jQuery Validate 插件为表单提供了强大的验证功能,不用自己去写各种验证。默认提示是英文,可以选择其他语言。

    简单使用

    <%@ page language="java" contentType="text/html; charset=UTF-8"
        pageEncoding="UTF-8"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Insert title here</title>
        <script type="text/javascript" src="jquery-validation-1.14.0/lib/jquery.js"></script>
        <script type="text/javascript" src="jquery-validation-1.14.0/dist/jquery.validate.min.js"></script>
        <script type="text/javascript" src="jquery-validation-1.14.0/dist/localization/messages_zh.js"></script>
        <script type="text/javascript">
            $(function(){
                $("#myform").validate(
                {
                    /* 重写错误显示消息方法,以alert方式弹出错误消息 */   
                    showErrors: function(errorMap, errorList) {   
                        var msg = "";   
                        $.each( errorList, function(i,v){   
                          msg += (v.message+"
    ");   
                        });   
                        if(msg!="") alert(msg);   
                    },   
                }        
                );
            })
        </script>
    </head>
    <body>
        <form id="myform" action="">
            <input type="text" minlength="5" required=true number=true>
            <input type="submit">
        </form>
    </body>
    </html>

    上面重写了信息的提示方式,改为以弹出框的形式提示信息。

    详细的使用看这 http://www.runoob.com/jquery/jquery-plugin-validate.html

  • 相关阅读:
    python从入门到实践-5章if语句
    HiveQL:文件格式和压缩方法
    HiveQL:调优
    HiveQL:模式设计
    HiveQL:视图
    (转)配置文件.bash_profile和.bashrc的区别
    Hive-学习总结(二)
    Hive-学习总结
    MYSQL-表类型(存储引擎)的选择
    MYSQL-常用函数
  • 原文地址:https://www.cnblogs.com/yeming/p/5459056.html
Copyright © 2011-2022 走看看