zoukankan      html  css  js  c++  java
  • jQuery.Validator Sample

    <!DOCTYPE html>
    <html>
        <head>
            <title></title>
            <script src="./js/jquery-1.11.3.min.js"></script>
            <script src="./js/jQuery-validation//dist/jquery.validate.min.js"></script>
        </head>
        <body>
            <script>
                $.validator.setDefaults({
                    submitHandler: function() {
                        alert("提交事件!");
                    }
                });
                $().ready(function() {
                    $("#commentForm").validate();
                });
            </script>
    
            <form class="cmxform" id="commentForm" method="get" action="">
                <fieldset>
                    <legend>输入您的名字,邮箱,URL,备注。</legend>
                    <p>
                        <label for="cname">Name (必需, 最小两个字母)</label>
                        <input id="cname" name="name" minlength="2" type="text" required>
                    </p>
                    <p>
                        <label for="cemail">E-Mail (必需)</label>
                        <input id="cemail" type="email" name="email" required>
                    </p>
                    <p>
                        <label for="curl">URL (可选)</label>
                        <input id="curl" type="url" name="url">
                    </p>
                    <p>
                        <label for="ccomment">备注 (必需)</label>
                        <textarea id="ccomment" name="comment" required></textarea>
                    </p>
                    <p>
                        <input class="submit" type="submit" value="Submit">
                    </p>
                </fieldset>
            </form>
        </body>
    </html>

    结果

    jQuery Validator的源码里有这么一段

    然后在插件的localization路径下有不同语言版本的message,

    引入不同的meessages的js文件可以覆盖掉源码当中的英文,最终实现不同语言版本的提示。

  • 相关阅读:
    LintCode "Maximum Gap"
    LintCode "Wood Cut"
    LintCode "Expression Evaluation"
    LintCode "Find Peak Element II"
    LintCode "Remove Node in Binary Search Tree"
    LintCode "Delete Digits"
    LintCode "Binary Representation"
    LeetCode "Game of Life"
    LintCode "Coins in a Line"
    LintCode "Word Break"
  • 原文地址:https://www.cnblogs.com/zcynine/p/5265345.html
Copyright © 2011-2022 走看看