jQuery-Validation-Engine-rails 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in jQuery-Validation-Engine-rails.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 qichunren
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,53 @@
1
+ # JQuery::Validation::Engine::Rails
2
+
3
+ [jQuery-Validation-Engine](https://github.com/posabsolute/jQuery-Validation-Engine) for rails project.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'jQuery-Validation-Engine-rails'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install jQuery-Validation-Engine-rails
18
+
19
+ ## Usage
20
+
21
+ ### CSS
22
+
23
+ ```
24
+ *= require validationEngine.jquery
25
+ ```
26
+
27
+ ### JS
28
+
29
+ ```
30
+ //= require jquery.validationEngine-zh_CN
31
+ //= require jquery.validationEngine
32
+ ```
33
+
34
+ ### CODE
35
+
36
+ Form field: `<%= f.text_field :name, :class => "span2 validate[required] text-input" %>`
37
+
38
+ ```
39
+ <script type="text/javascript">
40
+ $(document).ready(function(){
41
+ $("#form_id").validationEngine();
42
+ });
43
+ </script>
44
+ ```
45
+
46
+ ## Contributing
47
+
48
+ 1. Fork it
49
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
50
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
51
+ 4. Push to the branch (`git push origin my-new-feature`)
52
+ 5. Create new Pull Request
53
+
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require "bundler/gem_tasks"
2
+
3
+
4
+ # wget https://raw.github.com/posabsolute/jQuery-Validation-Engine/master/js/jquery.validationEngine.js
5
+ # wget https://raw.github.com/posabsolute/jQuery-Validation-Engine/master/js/languages/jquery.validationEngine-zh_CN.js
6
+ # wget https://raw.github.com/posabsolute/jQuery-Validation-Engine/master/js/languages/jquery.validationEngine-en.js
7
+ # wget https://raw.github.com/posabsolute/jQuery-Validation-Engine/master/css/validationEngine.jquery.css
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'jQuery-Validation-Engine-rails/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "jQuery-Validation-Engine-rails"
8
+ gem.version = JQuery::Validation::Engine::Rails::VERSION
9
+ gem.authors = ["qichunren"]
10
+ gem.email = ["whyruby@gmail.com"]
11
+ gem.description = %q{jQuery-Validation-Engine jquery plugin for rails project.}
12
+ gem.summary = %q{jQuery-Validation-Engine jquery plugin for rails project.}
13
+ gem.homepage = "https://github.com/qichunren/jQuery-Validation-Engine-rails"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+ end
@@ -0,0 +1,12 @@
1
+ require "jQuery-Validation-Engine-rails/version"
2
+ require "jQuery-Validation-Engine-rails/engine"
3
+
4
+ module JQuery
5
+ module Validation
6
+ module Engine
7
+ module Rails
8
+ # Your code goes here...
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ module JQuery
2
+ module Validation
3
+ module Engine
4
+ module Rails
5
+
6
+ class Engine < ::Rails::Engine
7
+ end
8
+ # Rails, will you please look in our vendor? kthx
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,9 @@
1
+ module JQuery
2
+ module Validation
3
+ module Engine
4
+ module Rails
5
+ VERSION = "0.0.1"
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,192 @@
1
+ (function($){
2
+ $.fn.validationEngineLanguage = function(){
3
+ };
4
+ $.validationEngineLanguage = {
5
+ newLang: function(){
6
+ $.validationEngineLanguage.allRules = {
7
+ "required": { // Add your regex rules here, you can take telephone as an example
8
+ "regex": "none",
9
+ "alertText": "* This field is required",
10
+ "alertTextCheckboxMultiple": "* Please select an option",
11
+ "alertTextCheckboxe": "* This checkbox is required",
12
+ "alertTextDateRange": "* Both date range fields are required"
13
+ },
14
+ "requiredInFunction": {
15
+ "func": function(field, rules, i, options){
16
+ return (field.val() == "test") ? true : false;
17
+ },
18
+ "alertText": "* Field must equal test"
19
+ },
20
+ "dateRange": {
21
+ "regex": "none",
22
+ "alertText": "* Invalid ",
23
+ "alertText2": "Date Range"
24
+ },
25
+ "dateTimeRange": {
26
+ "regex": "none",
27
+ "alertText": "* Invalid ",
28
+ "alertText2": "Date Time Range"
29
+ },
30
+ "minSize": {
31
+ "regex": "none",
32
+ "alertText": "* Minimum ",
33
+ "alertText2": " characters allowed"
34
+ },
35
+ "maxSize": {
36
+ "regex": "none",
37
+ "alertText": "* Maximum ",
38
+ "alertText2": " characters allowed"
39
+ },
40
+ "groupRequired": {
41
+ "regex": "none",
42
+ "alertText": "* You must fill one of the following fields"
43
+ },
44
+ "min": {
45
+ "regex": "none",
46
+ "alertText": "* Minimum value is "
47
+ },
48
+ "max": {
49
+ "regex": "none",
50
+ "alertText": "* Maximum value is "
51
+ },
52
+ "past": {
53
+ "regex": "none",
54
+ "alertText": "* Date prior to "
55
+ },
56
+ "future": {
57
+ "regex": "none",
58
+ "alertText": "* Date past "
59
+ },
60
+ "maxCheckbox": {
61
+ "regex": "none",
62
+ "alertText": "* Maximum ",
63
+ "alertText2": " options allowed"
64
+ },
65
+ "minCheckbox": {
66
+ "regex": "none",
67
+ "alertText": "* Please select ",
68
+ "alertText2": " options"
69
+ },
70
+ "equals": {
71
+ "regex": "none",
72
+ "alertText": "* Fields do not match"
73
+ },
74
+ "creditCard": {
75
+ "regex": "none",
76
+ "alertText": "* Invalid credit card number"
77
+ },
78
+ "phone": {
79
+ // credit: jquery.h5validate.js / orefalo
80
+ "regex": /^([\+][0-9]{1,3}[\ \.\-])?([\(]{1}[0-9]{2,6}[\)])?([0-9\ \.\-\/]{3,20})((x|ext|extension)[\ ]?[0-9]{1,4})?$/,
81
+ "alertText": "* Invalid phone number"
82
+ },
83
+ "email": {
84
+ // HTML5 compatible email regex ( http://www.whatwg.org/specs/web-apps/current-work/multipage/states-of-the-type-attribute.html# e-mail-state-%28type=email%29 )
85
+ "regex": /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,
86
+ "alertText": "* Invalid email address"
87
+ },
88
+ "integer": {
89
+ "regex": /^[\-\+]?\d+$/,
90
+ "alertText": "* Not a valid integer"
91
+ },
92
+ "number": {
93
+ // Number, including positive, negative, and floating decimal. credit: orefalo
94
+ "regex": /^[\-\+]?((([0-9]{1,3})([,][0-9]{3})*)|([0-9]+))?([\.]([0-9]+))?$/,
95
+ "alertText": "* Invalid floating decimal number"
96
+ },
97
+ "date": {
98
+ // Check if date is valid by leap year
99
+ "func": function (field) {
100
+ var pattern = new RegExp(/^(\d{4})[\/\-\.](0?[1-9]|1[012])[\/\-\.](0?[1-9]|[12][0-9]|3[01])$/);
101
+ var match = pattern.exec(field.val());
102
+ if (match == null)
103
+ return false;
104
+
105
+ var year = match[1];
106
+ var month = match[2]*1;
107
+ var day = match[3]*1;
108
+ var date = new Date(year, month - 1, day); // because months starts from 0.
109
+
110
+ return (date.getFullYear() == year && date.getMonth() == (month - 1) && date.getDate() == day);
111
+ },
112
+ "alertText": "* Invalid date, must be in YYYY-MM-DD format"
113
+ },
114
+ "ipv4": {
115
+ "regex": /^((([01]?[0-9]{1,2})|(2[0-4][0-9])|(25[0-5]))[.]){3}(([0-1]?[0-9]{1,2})|(2[0-4][0-9])|(25[0-5]))$/,
116
+ "alertText": "* Invalid IP address"
117
+ },
118
+ "url": {
119
+ "regex": /^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i,
120
+ "alertText": "* Invalid URL"
121
+ },
122
+ "onlyNumberSp": {
123
+ "regex": /^[0-9\ ]+$/,
124
+ "alertText": "* Numbers only"
125
+ },
126
+ "onlyLetterSp": {
127
+ "regex": /^[a-zA-Z\ \']+$/,
128
+ "alertText": "* Letters only"
129
+ },
130
+ "onlyLetterNumber": {
131
+ "regex": /^[0-9a-zA-Z]+$/,
132
+ "alertText": "* No special characters allowed"
133
+ },
134
+ // --- CUSTOM RULES -- Those are specific to the demos, they can be removed or changed to your likings
135
+ "ajaxUserCall": {
136
+ "url": "ajaxValidateFieldUser",
137
+ // you may want to pass extra data on the ajax call
138
+ "extraData": "name=eric",
139
+ "alertText": "* This user is already taken",
140
+ "alertTextLoad": "* Validating, please wait"
141
+ },
142
+ "ajaxUserCallPhp": {
143
+ "url": "phpajax/ajaxValidateFieldUser.php",
144
+ // you may want to pass extra data on the ajax call
145
+ "extraData": "name=eric",
146
+ // if you provide an "alertTextOk", it will show as a green prompt when the field validates
147
+ "alertTextOk": "* This username is available",
148
+ "alertText": "* This user is already taken",
149
+ "alertTextLoad": "* Validating, please wait"
150
+ },
151
+ "ajaxNameCall": {
152
+ // remote json service location
153
+ "url": "ajaxValidateFieldName",
154
+ // error
155
+ "alertText": "* This name is already taken",
156
+ // if you provide an "alertTextOk", it will show as a green prompt when the field validates
157
+ "alertTextOk": "* This name is available",
158
+ // speaks by itself
159
+ "alertTextLoad": "* Validating, please wait"
160
+ },
161
+ "ajaxNameCallPhp": {
162
+ // remote json service location
163
+ "url": "phpajax/ajaxValidateFieldName.php",
164
+ // error
165
+ "alertText": "* This name is already taken",
166
+ // speaks by itself
167
+ "alertTextLoad": "* Validating, please wait"
168
+ },
169
+ "validate2fields": {
170
+ "alertText": "* Please input HELLO"
171
+ },
172
+ //tls warning:homegrown not fielded
173
+ "dateFormat":{
174
+ "regex": /^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$|^(?:(?:(?:0?[13578]|1[02])(\/|-)31)|(?:(?:0?[1,3-9]|1[0-2])(\/|-)(?:29|30)))(\/|-)(?:[1-9]\d\d\d|\d[1-9]\d\d|\d\d[1-9]\d|\d\d\d[1-9])$|^(?:(?:0?[1-9]|1[0-2])(\/|-)(?:0?[1-9]|1\d|2[0-8]))(\/|-)(?:[1-9]\d\d\d|\d[1-9]\d\d|\d\d[1-9]\d|\d\d\d[1-9])$|^(0?2(\/|-)29)(\/|-)(?:(?:0[48]00|[13579][26]00|[2468][048]00)|(?:\d\d)?(?:0[48]|[2468][048]|[13579][26]))$/,
175
+ "alertText": "* Invalid Date"
176
+ },
177
+ //tls warning:homegrown not fielded
178
+ "dateTimeFormat": {
179
+ "regex": /^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])\s+(1[012]|0?[1-9]){1}:(0?[1-5]|[0-6][0-9]){1}:(0?[0-6]|[0-6][0-9]){1}\s+(am|pm|AM|PM){1}$|^(?:(?:(?:0?[13578]|1[02])(\/|-)31)|(?:(?:0?[1,3-9]|1[0-2])(\/|-)(?:29|30)))(\/|-)(?:[1-9]\d\d\d|\d[1-9]\d\d|\d\d[1-9]\d|\d\d\d[1-9])$|^((1[012]|0?[1-9]){1}\/(0?[1-9]|[12][0-9]|3[01]){1}\/\d{2,4}\s+(1[012]|0?[1-9]){1}:(0?[1-5]|[0-6][0-9]){1}:(0?[0-6]|[0-6][0-9]){1}\s+(am|pm|AM|PM){1})$/,
180
+ "alertText": "* Invalid Date or Date Format",
181
+ "alertText2": "Expected Format: ",
182
+ "alertText3": "mm/dd/yyyy hh:mm:ss AM|PM or ",
183
+ "alertText4": "yyyy-mm-dd hh:mm:ss AM|PM"
184
+ }
185
+ };
186
+
187
+ }
188
+ };
189
+
190
+ $.validationEngineLanguage.newLang();
191
+
192
+ })(jQuery);
@@ -0,0 +1,177 @@
1
+ (function($){
2
+ $.fn.validationEngineLanguage = function(){
3
+ };
4
+ $.validationEngineLanguage = {
5
+ newLang: function(){
6
+ $.validationEngineLanguage.allRules = {
7
+ "required": { // Add your regex rules here, you can take telephone as an example
8
+ "regex": "none",
9
+ "alertText": "* 此处不可空白",
10
+ "alertTextCheckboxMultiple": "* 请选择一个项目",
11
+ "alertTextCheckboxe": "* 您必须钩选此栏",
12
+ "alertTextDateRange": "* 日期范围不可空白"
13
+ },
14
+ "requiredInFunction": {
15
+ "func": function(field, rules, i, options){
16
+ return (field.val() == "test") ? true : false;
17
+ },
18
+ "alertText": "* Field must equal test"
19
+ },
20
+ "dateRange": {
21
+ "regex": "none",
22
+ "alertText": "* 无效的 ",
23
+ "alertText2": " 日期范围"
24
+ },
25
+ "dateTimeRange": {
26
+ "regex": "none",
27
+ "alertText": "* 无效的 ",
28
+ "alertText2": " 时间范围"
29
+ },
30
+ "minSize": {
31
+ "regex": "none",
32
+ "alertText": "* 最少 ",
33
+ "alertText2": " 个字符"
34
+ },
35
+ "maxSize": {
36
+ "regex": "none",
37
+ "alertText": "* 最多 ",
38
+ "alertText2": " 个字符"
39
+ },
40
+ "groupRequired": {
41
+ "regex": "none",
42
+ "alertText": "* 你必需选填其中一个栏位"
43
+ },
44
+ "min": {
45
+ "regex": "none",
46
+ "alertText": "* 最小值為 "
47
+ },
48
+ "max": {
49
+ "regex": "none",
50
+ "alertText": "* 最大值为 "
51
+ },
52
+ "past": {
53
+ "regex": "none",
54
+ "alertText": "* 日期必需早于 "
55
+ },
56
+ "future": {
57
+ "regex": "none",
58
+ "alertText": "* 日期必需晚于 "
59
+ },
60
+ "maxCheckbox": {
61
+ "regex": "none",
62
+ "alertText": "* 最多选取 ",
63
+ "alertText2": " 个项目"
64
+ },
65
+ "minCheckbox": {
66
+ "regex": "none",
67
+ "alertText": "* 请选择 ",
68
+ "alertText2": " 个项目"
69
+ },
70
+ "equals": {
71
+ "regex": "none",
72
+ "alertText": "* 请输入与上面相同的密码"
73
+ },
74
+ "creditCard": {
75
+ "regex": "none",
76
+ "alertText": "* 无效的信用卡号码"
77
+ },
78
+ "phone": {
79
+ // credit: jquery.h5validate.js / orefalo
80
+ "regex": /^([\+][0-9]{1,3}[ \.\-])?([\(]{1}[0-9]{2,6}[\)])?([0-9 \.\-\/]{3,20})((x|ext|extension)[ ]?[0-9]{1,4})?$/,
81
+ "alertText": "* 无效的电话号码"
82
+ },
83
+ "email": {
84
+ // Shamelessly lifted from Scott Gonzalez via the Bassistance Validation plugin http://projects.scottsplayground.com/email_address_validation/
85
+ "regex": /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i,
86
+ "alertText": "* 邮件地址无效"
87
+ },
88
+ "integer": {
89
+ "regex": /^[\-\+]?\d+$/,
90
+ "alertText": "* 不是有效的整数"
91
+ },
92
+ "number": {
93
+ // Number, including positive, negative, and floating decimal. credit: orefalo
94
+ "regex": /^[\-\+]?((([0-9]{1,3})([,][0-9]{3})*)|([0-9]+))?([\.]([0-9]+))?$/,
95
+ "alertText": "* 无效的数字"
96
+ },
97
+ "date": {
98
+ "regex": /^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$/,
99
+ "alertText": "* 无效的日期,格式必需为 YYYY-MM-DD"
100
+ },
101
+ "ipv4": {
102
+ "regex": /^((([01]?[0-9]{1,2})|(2[0-4][0-9])|(25[0-5]))[.]){3}(([0-1]?[0-9]{1,2})|(2[0-4][0-9])|(25[0-5]))$/,
103
+ "alertText": "* 无效的 IP 地址"
104
+ },
105
+ "url": {
106
+ "regex": /^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i,
107
+ "alertText": "* Invalid URL"
108
+ },
109
+ "onlyNumberSp": {
110
+ "regex": /^[0-9\ ]+$/,
111
+ "alertText": "* 只能填数字"
112
+ },
113
+ "onlyLetterSp": {
114
+ "regex": /^[a-zA-Z\ \']+$/,
115
+ "alertText": "* 只接受英文字母大小写"
116
+ },
117
+ "onlyLetterNumber": {
118
+ "regex": /^[0-9a-zA-Z]+$/,
119
+ "alertText": "* 不接受特殊字符"
120
+ },
121
+ // --- CUSTOM RULES -- Those are specific to the demos, they can be removed or changed to your likings
122
+ "ajaxUserCall": {
123
+ "url": "ajaxValidateFieldUser",
124
+ // you may want to pass extra data on the ajax call
125
+ "extraData": "name=eric",
126
+ "alertText": "* 此名称已被其他人使用",
127
+ "alertTextLoad": "* 正在确认名称是否有其他人使用,请稍等。"
128
+ },
129
+ "ajaxUserCallPhp": {
130
+ "url": "phpajax/ajaxValidateFieldUser.php",
131
+ // you may want to pass extra data on the ajax call
132
+ "extraData": "name=eric",
133
+ // if you provide an "alertTextOk", it will show as a green prompt when the field validates
134
+ "alertTextOk": "* 此帐号名称可以使用",
135
+ "alertText": "* 此名称已被其他人使用",
136
+ "alertTextLoad": "* 正在确认帐号名称是否有其他人使用,请稍等。"
137
+ },
138
+ "ajaxNameCall": {
139
+ // remote json service location
140
+ "url": "ajaxValidateFieldName",
141
+ // error
142
+ "alertText": "* 此名称可以使用",
143
+ // if you provide an "alertTextOk", it will show as a green prompt when the field validates
144
+ "alertTextOk": "* 此名称已被其他人使用",
145
+ // speaks by itself
146
+ "alertTextLoad": "* 正在确认名称是否有其他人使用,请稍等。"
147
+ },
148
+ "ajaxNameCallPhp": {
149
+ // remote json service location
150
+ "url": "phpajax/ajaxValidateFieldName.php",
151
+ // error
152
+ "alertText": "* 此名称已被其他人使用",
153
+ // speaks by itself
154
+ "alertTextLoad": "* 正在确认名称是否有其他人使用,请稍等。"
155
+ },
156
+ "validate2fields": {
157
+ "alertText": "* 请输入 HELLO"
158
+ },
159
+ //tls warning:homegrown not fielded
160
+ "dateFormat":{
161
+ "regex": /^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$|^(?:(?:(?:0?[13578]|1[02])(\/|-)31)|(?:(?:0?[1,3-9]|1[0-2])(\/|-)(?:29|30)))(\/|-)(?:[1-9]\d\d\d|\d[1-9]\d\d|\d\d[1-9]\d|\d\d\d[1-9])$|^(?:(?:0?[1-9]|1[0-2])(\/|-)(?:0?[1-9]|1\d|2[0-8]))(\/|-)(?:[1-9]\d\d\d|\d[1-9]\d\d|\d\d[1-9]\d|\d\d\d[1-9])$|^(0?2(\/|-)29)(\/|-)(?:(?:0[48]00|[13579][26]00|[2468][048]00)|(?:\d\d)?(?:0[48]|[2468][048]|[13579][26]))$/,
162
+ "alertText": "* 无效的日期格式"
163
+ },
164
+ //tls warning:homegrown not fielded
165
+ "dateTimeFormat": {
166
+ "regex": /^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])\s+(1[012]|0?[1-9]){1}:(0?[1-5]|[0-6][0-9]){1}:(0?[0-6]|[0-6][0-9]){1}\s+(am|pm|AM|PM){1}$|^(?:(?:(?:0?[13578]|1[02])(\/|-)31)|(?:(?:0?[1,3-9]|1[0-2])(\/|-)(?:29|30)))(\/|-)(?:[1-9]\d\d\d|\d[1-9]\d\d|\d\d[1-9]\d|\d\d\d[1-9])$|^((1[012]|0?[1-9]){1}\/(0?[1-9]|[12][0-9]|3[01]){1}\/\d{2,4}\s+(1[012]|0?[1-9]){1}:(0?[1-5]|[0-6][0-9]){1}:(0?[0-6]|[0-6][0-9]){1}\s+(am|pm|AM|PM){1})$/,
167
+ "alertText": "* 无效的日期或时间格式",
168
+ "alertText2": "可接受的格式: ",
169
+ "alertText3": "mm/dd/yyyy hh:mm:ss AM|PM 或 ",
170
+ "alertText4": "yyyy-mm-dd hh:mm:ss AM|PM"
171
+ }
172
+ };
173
+
174
+ }
175
+ };
176
+ $.validationEngineLanguage.newLang();
177
+ })(jQuery);