实例代码“Ctrl+/”提示“F11/ESC”全屏 返回 格式化 恢复 运行
x
 
1
<!DOCTYPE html>
2
<html>
3
    <head>
4
        <meta content="text/html;charset=utf-8" http-equiv="Content-Type" />
5
        <link rel="stylesheet" href="//ku.shouce.ren/libs/validation-engine/2.6.2/css/validationEngine.jquery.css">
6
        <script type="text/javascript" src="https://ku.shouce.ren/libs/jquery/1/jquery1.7.2.min.js">
7
        </script>
8
        <script src="//ku.shouce.ren/libs/validation-engine/2.6.2/js/jquery.validationEngine-zh_CN.js">
9
        </script>
10
        <script src="//ku.shouce.ren/libs/validation-engine/2.6.2/js/jquery.validationEngine.min.js">
11
        </script>
12
    </head>
13
    <body>
14
        <div class="main">
15
            <div class="inwrap">
16
                <h1>jQuery Validation Engine 表单验证中文版
17
                </h1>
18
                <h2>只显示一个提示信息
19
                </h2>
20
                <div class="detail">
21
                    <p>通过参数
22
                        <code>showOneMessage
23
                        </code>设置,是否在表单验证的时候,只显示一个提示信息。
24
                    </p>
25
                </div>
26
                <div class="example">
27
                    <form id="formID" class="formular" method="post">
28
                        <fieldset>
29
                            <legend>必填项
30
                            </legend>
31
                            <input value="" data-validation-engine="validate[required]" class="text-input" type="text" name="req" id="req">
32
                            <label>喜欢的运动 1:
33
                            </label>
34
                            <select name="sport" id="sport" data-validation-engine="validate[required]">
35
                                <option value="">选择一项运动
36
                                </option>
37
                                <option value="option1">网球
38
                                </option>
39
                                <option value="option2">足球
40
                                </option>
41
                                <option value="option3">高尔夫球
42
                                </option>
43
                            </select>
44
                            <label>喜欢的运动 2:
45
                            </label>
46
                            <select name="sport2" id="sport2" multiple data-validation-engine="validate[required]">
47
                                <option value="">选择一项运动
48
                                </option>
49
                                <option value="option1">网球
50
                                </option>
51
                                <option value="option2">足球
52
                                </option>
53
                                <option value="option3">高尔夫球
54
                                </option>
55
                            </select>
56
                            <code>validate[required]
57
                            </code>
58
                        </fieldset>
59
                        <input class="submit" type="submit" value="验证 & 提交表单">
60
                    </form>
61
                </div>
62
            </div>
63
        </div>
64
        <script>
65
            jQuery(document).ready(function(){
66
                // binds form submission and fields to the validation engine
67
                jQuery('#formID').validationEngine({
68
                    showOneMessage: true
69
                }
70
                                                  );
71
            }
72
                                  );
73
        </script>
74
    </body>
75
</html>
76