dqs-jquery-form-validator-rails 2.2.8

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.
Files changed (45) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +21 -0
  3. data/CHANGELOG.md +4 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE +24 -0
  6. data/README.md +477 -0
  7. data/Rakefile +1 -0
  8. data/dqs-jquery-form-validator.gemspec +27 -0
  9. data/lib/dqs/jquery/form/validator/rails/engine.rb +12 -0
  10. data/lib/dqs/jquery/form/validator/rails/version.rb +11 -0
  11. data/lib/dqs/jquery/form/validator/rails.rb +13 -0
  12. data/lib/dqs-jquery-form-validator-rails.rb +1 -0
  13. data/vendor/assets/javascripts/dqs-jquery-form-validator/brazil.js +9 -0
  14. data/vendor/assets/javascripts/dqs-jquery-form-validator/date.js +9 -0
  15. data/vendor/assets/javascripts/dqs-jquery-form-validator/file.js +9 -0
  16. data/vendor/assets/javascripts/dqs-jquery-form-validator/html5.js +9 -0
  17. data/vendor/assets/javascripts/dqs-jquery-form-validator/jquery.form-validator.js +2108 -0
  18. data/vendor/assets/javascripts/dqs-jquery-form-validator/jquery.form-validator.min.js +9 -0
  19. data/vendor/assets/javascripts/dqs-jquery-form-validator/jsconf.js +9 -0
  20. data/vendor/assets/javascripts/dqs-jquery-form-validator/lang/ca.js +9 -0
  21. data/vendor/assets/javascripts/dqs-jquery-form-validator/lang/cz.js +9 -0
  22. data/vendor/assets/javascripts/dqs-jquery-form-validator/lang/de.js +9 -0
  23. data/vendor/assets/javascripts/dqs-jquery-form-validator/lang/dk.js +9 -0
  24. data/vendor/assets/javascripts/dqs-jquery-form-validator/lang/es.js +9 -0
  25. data/vendor/assets/javascripts/dqs-jquery-form-validator/lang/fr.js +9 -0
  26. data/vendor/assets/javascripts/dqs-jquery-form-validator/lang/it.js +9 -0
  27. data/vendor/assets/javascripts/dqs-jquery-form-validator/lang/nl.js +9 -0
  28. data/vendor/assets/javascripts/dqs-jquery-form-validator/lang/no.js +9 -0
  29. data/vendor/assets/javascripts/dqs-jquery-form-validator/lang/pl.js +9 -0
  30. data/vendor/assets/javascripts/dqs-jquery-form-validator/lang/pt.js +9 -0
  31. data/vendor/assets/javascripts/dqs-jquery-form-validator/lang/ro.js +9 -0
  32. data/vendor/assets/javascripts/dqs-jquery-form-validator/lang/ru.js +9 -0
  33. data/vendor/assets/javascripts/dqs-jquery-form-validator/lang/sv.js +9 -0
  34. data/vendor/assets/javascripts/dqs-jquery-form-validator/location.js +9 -0
  35. data/vendor/assets/javascripts/dqs-jquery-form-validator/logic.js +9 -0
  36. data/vendor/assets/javascripts/dqs-jquery-form-validator/poland.js +9 -0
  37. data/vendor/assets/javascripts/dqs-jquery-form-validator/sanitize.js +9 -0
  38. data/vendor/assets/javascripts/dqs-jquery-form-validator/security.js +9 -0
  39. data/vendor/assets/javascripts/dqs-jquery-form-validator/sepa.js +9 -0
  40. data/vendor/assets/javascripts/dqs-jquery-form-validator/sweden.js +9 -0
  41. data/vendor/assets/javascripts/dqs-jquery-form-validator/theme-default.css +107 -0
  42. data/vendor/assets/javascripts/dqs-jquery-form-validator/theme-default.min.css +1 -0
  43. data/vendor/assets/javascripts/dqs-jquery-form-validator/toggleDisabled.js +9 -0
  44. data/vendor/assets/javascripts/dqs-jquery-form-validator/uk.js +9 -0
  45. metadata +140 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0b2d51a532004d7112c97f96b9e1c65d0df2ebd5
4
+ data.tar.gz: c84f5c7e84f4edd3e2400b4118ca3a9772bb9f3d
5
+ SHA512:
6
+ metadata.gz: fa0f978b5d5cc8a6c597b76f0a26e8f9918b975a3b665cf4e0d3aadbcc7eb3f6363f4d07cb04fdc6082d2ea0761706a9c6a2eac6611cf8b5848915cf1141a719
7
+ data.tar.gz: 3a87e008691d4239bf0e450ebbfa3bd54e8572329e1db2f36681429a3500cf98aad7f0d28bcb76e4e8e41a4b10e5fe4bdf6ba6bd9c999e2b6e59115311c276f3
data/.gitignore ADDED
@@ -0,0 +1,21 @@
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
18
+ .DS_Store
19
+ .Trashes
20
+ .Spotlight-V100
21
+ .phpintel
data/CHANGELOG.md ADDED
@@ -0,0 +1,4 @@
1
+
2
+ ## 0.0.1
3
+
4
+ * Initialize the jQuery form validator gem
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in jquery-form-validator-rails.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,24 @@
1
+ Copyright (c) 2014 Gustaf Lindqvist
2
+
3
+ jQuery Copyright (c)2012 jQuery Foundation and other contributors
4
+
5
+ MIT License
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining
8
+ a copy of this software and associated documentation files (the
9
+ "Software"), to deal in the Software without restriction, including
10
+ without limitation the rights to use, copy, modify, merge, publish,
11
+ distribute, sublicense, and/or sell copies of the Software, and to
12
+ permit persons to whom the Software is furnished to do so, subject to
13
+ the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be
16
+ included in all copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,477 @@
1
+ # DQS::Jquery::Form::Validator::Rails
2
+
3
+ DQS-Jquery-form-validator-rails gem is based on Victor Jonsson's jQuery plugin: https://github.com/victorjonsson/jQuery-Form-Validator
4
+
5
+ DQS-jQuery-Form-Validator:
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+ ```
11
+ vim Gemfile
12
+ [...]
13
+ gem 'dqs-jquery-form-validator-rails', '>= 2.2.8'
14
+ ```
15
+
16
+ And then execute:
17
+ ```
18
+ bundle install
19
+ ````
20
+
21
+ ### Include jquery.form-validator-rails javascript assets
22
+
23
+ Add the following to your `app/assets/javascripts/application.js`:
24
+ ```
25
+ //= require jquery
26
+ //= require dqs-jquery-form-validator/jquery.form-validator.min
27
+ [...]
28
+ ```
29
+
30
+ For production environment you need to set up all the dependences you want to use because the assets pipeline, for example we can use the toggleDisabled, security, date and the lang equal portuguese
31
+
32
+
33
+ Add the following to your `app/assets/javascripts/application.js`:
34
+ ```
35
+ [...]
36
+ //= require jquery
37
+ //= require jquery.turbolinks
38
+ [...]
39
+ //= require dqs-jquery-form-validator/jquery.form-validator.min
40
+ //= require dqs-jquery-form-validator/toggleDisabled
41
+ //= require dqs-jquery-form-validator/security
42
+ //= require dqs-jquery-form-validator/date
43
+ //= require dqs-jquery-form-validator/lang/pt
44
+ //= require_tree .
45
+ ```
46
+
47
+ ### Easy example
48
+
49
+ Example how to add Jquery Form Validator to FormHelper `text_field`:
50
+
51
+ <div class="controls">
52
+ <%= f.text_field(:example, class: "field", data: {
53
+ :validation => "required validate_max_length length50",
54
+ "validation-error-msg" => "This field is required and cannot be longer than 50 characters."
55
+ }) %>
56
+ </div>
57
+
58
+ Then add following to your `app/assets/javascripts/application.js`
59
+
60
+ <script>
61
+ $(document).ready(function() {
62
+ $.validate();
63
+ });
64
+ </script>
65
+
66
+ If you are using CoffeeScript we can setup as following enabling some modules such as: toggleDisabled, security, date and setting up the lang to portuguese
67
+ ```
68
+ [...]
69
+ jQuery ->
70
+ # Setup form validation on all forms
71
+ $.validate(
72
+ addValidClassOnAll : true,
73
+ lang: 'pt',
74
+ modules : 'toggleDisabled, security, date'
75
+ )
76
+ ```
77
+
78
+ Other configuration options can be seen here: http://formvalidator.net/#configuration
79
+
80
+ ## Credits
81
+
82
+ #### Maintainer
83
+
84
+ [Douglas Quintiliano dos Santos](https://github.com/douglasqsantos)
85
+
86
+ #### Contributors
87
+ <a href="https://github.com/douglasqsantos" target="_blank">Douglas Quintiliano dos Santos</a><br />
88
+
89
+
90
+ # jQuery Form Validator (The default Documentation)
91
+
92
+ jQuery Form Validator is a **feature rich and multilingual** jQuery plugin that makes it easy to validate user input while keeping your HTML markup clean from javascript code. Even though this plugin has a wide range of validation functions it's **designed to require as little network traffic as possible**. This is achieved by grouping together validation functions in "modules", making it possible to load only those functions that's needed to validate a particular form.
93
+
94
+ **Form demos and full documentation available at http://formvalidator.net/**
95
+
96
+ [![Travis](https://travis-ci.org/victorjonsson/PHP-Markdown-Documentation-Generator.svg)](https://travis-ci.org/victorjonsson/jQuery-Form-Validator/builds/)
97
+
98
+ *Usage example*
99
+
100
+ ```html
101
+ <form action="" method="POST">
102
+ <p>
103
+ Name (4 characters minimum):
104
+ <input name="user" data-validation="length" data-validation-length="min4" />
105
+ </p>
106
+ <p>
107
+ Birthdate (yyyy-mm-dd):
108
+ <input name="birth" data-validation="birthdate" />
109
+ </p>
110
+ <p>
111
+ Website:
112
+ <input name="website" data-validation="url" />
113
+ </p>
114
+ <p>
115
+ <input type="submit" />
116
+ </p>
117
+ </form>
118
+ <script src="js/jquery.min.js"></script>
119
+ <script src="js/form-validator/jquery.form-validator.min.js"></script>
120
+ <script>
121
+ /* important to locate this script AFTER the closing form element, so form object is loaded in DOM before setup is called */
122
+ $.validate({
123
+ modules : 'date, security'
124
+ });
125
+ </script>
126
+ ```
127
+
128
+ ### Support for HTML5
129
+
130
+ As of version 2.2 (unreleased) you can use this plugin as a fallback solution for the validation attributes in the HTML5 spec. Add the module `html5` to the module declaration and you can use the following native features:
131
+
132
+ **Attributes**: require, pattern, maxlength, min, max, placeholder
133
+
134
+ **Input types**: url, date, time, email, number
135
+
136
+ **Elements**: Use the element `datalist` to create input suggestions
137
+
138
+
139
+ ### Default validators and features (no module needed)
140
+ * **url**
141
+ * **email**
142
+ * **domain** — *domain.com*
143
+ * **number** — *float/negative/positive/range/step*
144
+ * **date** — *yyyy-mm-dd (format can be customized, more information below)*
145
+ * **alphanumeric** — *with support for defining additional characters*
146
+ * **length** — *min/max/range*
147
+ * **required** — *no validation except that a value has to be given*
148
+ * **custom** — *Validate value against regexp*
149
+ * **checkboxgroup** — *ensure at least 1 checkbox in group has been selected*
150
+ * Show help information automatically when input is focused
151
+ * Validate given values immediately when input looses focus.
152
+ * Make validation optional by adding attribute data-validation-optional="true" to the element. This means
153
+ that the validation defined in data-validation only will take place in case a value is given.
154
+ * Make validation dependent on another input of type checkbox being checked by adding attribute
155
+ data-validation-if-checked="name of checkbox input"
156
+ * Create input suggestions with ease, no jquery-ui needed
157
+ * to apply multiple validators to an input element, separate the validator names using a space (ex: required email)
158
+
159
+ Read the documentation for the default features at [http://formvalidator.net/#default-validators](http://formvalidator.net/#default-validators)
160
+
161
+ ### Module: security
162
+ * **spamcheck**
163
+ * **confirmation**
164
+ * **creditcard**
165
+ * **CVV**
166
+ * **strength** — *Validate the strength of a password*
167
+ * **server** — *Validate value of input on server side*
168
+ * **letternumeric** — *Validate that the input value consists out of only letters and/or numbers*
169
+
170
+ Read the documentation for the security module at [http://formvalidator.net/#security-validators](http://formvalidator.net/#security-validators)
171
+
172
+ ### Module: date
173
+ * **time** — *hh:mm*
174
+ * **birthdate** — *yyyy-mm-dd, not allowing dates in the future or dates that's older than 122 years (format can be customized, more information below)*
175
+
176
+ Read the documentation for the date module at [http://formvalidator.net/#date-validators](http://formvalidator.net/#date-validators)
177
+
178
+ ### Module: location
179
+ * **country**
180
+ * **federatestate**
181
+ * **longlat**
182
+ * Suggest countries (english only)
183
+ * Suggest states in the US
184
+
185
+ Read the documentation for the location module at [http://formvalidator.net/#location-validators](http://formvalidator.net/#location-validators)
186
+
187
+ ### Module: file
188
+ * **mime**
189
+ * **extension**
190
+ * **size** (file size)
191
+ * **dimension** (size dimension and ratio)
192
+
193
+ Read the documentation for the file module at [http://formvalidator.net/#file-validators](http://formvalidator.net/#file-validators)
194
+
195
+ ### Module: sweden
196
+ * **swemob** — *validate that the value is a swedish mobile telephone number*
197
+ * **swesec** — *validate swedish social security number*
198
+ * **county** - *validate that the value is an existing county in Sweden*
199
+ * **municipality** - *validate that the value is an existing municipality in Sweden*
200
+ * Suggest county
201
+ * Suggest municipality
202
+
203
+ Read the documentation for the Swedish module at [http://formvalidator.net/#sweden-validators](http://formvalidator.net/#sweden-validators)
204
+
205
+ ### Module: uk
206
+ * **ukvatnumber**
207
+
208
+ Read the documentation for the UK module at [http://formvalidator.net/#uk-validators](http://formvalidator.net/#uk-validators)
209
+
210
+ ### Module: brazil
211
+ * **brphone** — Validate a brazilian telephone number
212
+ * **cep**
213
+ * **cpf**
214
+
215
+ ### Module: sanitation
216
+ * **trim**
217
+ * **trimLeft**
218
+ * **trimRight**
219
+ * **upper** — (convert all letters to upper case)
220
+ * **lower** — (convert all letters to lower case)
221
+ * **capitalize** — (convert the first letter in all words to upper case)
222
+ * **insertRight** — (declare a text that should be inserted at the end of the value, attribute data-sanitize-insert-right)
223
+ * **insertLeft** — (declare a text that should be inserted at the beginning of the value, attribute data-sanitize-insert-left)
224
+ * **escape** — (convert < > & ' " to html entities)
225
+ * **numberFormat** — (declare the attribute data-sanitize-number-format with any of the formats described on http://numeraljs.com/. Note that this rule requires that numeral.js is included in the page)
226
+
227
+ Read the documentation for the sanitation module at [http://formvalidator.net/#data-sanitation](http://formvalidator.net/#data-sanitation)
228
+
229
+
230
+ ## Writing a custom validator
231
+ You can use the function `$.formUtils.addValidator()` to add your own validation function. Here's an example of a validator
232
+ that checks if the input contains an even number.
233
+
234
+ ```html
235
+ <form action="" method="POST">
236
+ <p>
237
+ <input type="text" data-validation="even" />
238
+ </p>
239
+ ...
240
+ </form>
241
+ <script src="js/jquery.min.js"></script>
242
+ <script src="js/form-validator/jquery.form-validator.min.js"></script>
243
+ <script>
244
+
245
+ // Add validator
246
+ $.formUtils.addValidator({
247
+ name : 'even',
248
+ validatorFunction : function(value, $el, config, language, $form) {
249
+ return parseInt(value, 10) % 2 === 0;
250
+ },
251
+ errorMessage : 'You have to answer an even number',
252
+ errorMessageKey: 'badEvenNumber'
253
+ });
254
+
255
+ // Initiate form validation
256
+ $.validate();
257
+
258
+ </script>
259
+ ```
260
+
261
+ ### Required properties passed into $.formUtils.addValidator
262
+
263
+ *name* - The name of the validator, which is used in the validation attribute of the input element.
264
+
265
+ *validatorFunction* - Callback function that validates the input. Should return a boolean telling if the value is considered valid or not.
266
+
267
+ *errorMessageKey* - Name of language property that is used in case the value of the input is invalid.
268
+
269
+ *errorMessage* - An alternative error message that is used if errorMessageKey is left with an empty value or isn't defined
270
+ in the language object. Note that you also can use [inline error messages](http://formvalidator.net/#localization) in your form.
271
+
272
+
273
+ The validation function takes these five arguments:
274
+ - value — the value of the input thats being validated
275
+ - $el — jQuery object referring to the input element being validated
276
+ - config — Object containing the configuration of this form validation
277
+ - language — Object with error dialogs
278
+ - $form — jQuery object referring to the form element being validated
279
+
280
+ ## Creating a custom module
281
+
282
+ A "module" is basically a javascript file containing one or more calls to [$.formUtils.addValidator()](#writing-a-custom-validator). The module file
283
+ should either have the file extension *.js* (as an ordinary javascript file) or *.dev.js*.
284
+
285
+ Using the file extension **.dev.js** will tell *$.formUtils.loadModules* to always append a timestamp to the end of the
286
+ URL, so that the browser never caches the file. You should of course never use *.dev.js* on a production website.
287
+
288
+ ### Loading your module ###
289
+
290
+ ```html
291
+ <html>
292
+ <head>
293
+ <script src="js/form-validator/jquery.form-validator.min.js"></script>
294
+ <script>
295
+ $.formUtils.loadModules('mymodule.dev', 'js/validation-modules/');
296
+ </script>
297
+ </head>
298
+ </html>
299
+ ...
300
+ ```
301
+
302
+ The first argument of $.formUtils.loadModules is a comma separated string with names of module files, without
303
+ file extension (add .dev if the file name is for example mymodule.dev.js, this will insure that the browser never
304
+ caches the javascript).
305
+
306
+ The second argument is the path where the module files is located. This argument is optional, if not given
307
+ the module files has to be located in the same directory as the core modules shipped together with this jquery plugin
308
+ (js/form-validator/)
309
+
310
+ ## Show help information
311
+ It is possible to display help information for each input. The information will fade in when input is focused and fade out when input looses focus.
312
+
313
+ ```html
314
+ <form action="" id="my_form">
315
+ <p>
316
+ <strong>Why not:</strong>
317
+ <textarea name="why" data-validation-help="Please give us some more information" data-validation="required"></textarea>
318
+ </p>
319
+ ...
320
+ ```
321
+
322
+ ## Fully customizable
323
+
324
+ Read about how to customize this plugin over at [http://formvalidator.net/#configuration](http://formvalidator.net/#configuration)
325
+
326
+ ### Validate On Event ###
327
+ You can cause an element to be validated upon the firing of an event, by attaching an attribute to the form input element named `data-validation-event="click"`. When the configuration settings have `validateOnEvent : true`, the click event will trigger the onBlur validaton for that element. Possible use case: Checkboxes. Instead of waiting for the checkbox to lose focus (blur) and waiting for a validation to occurr, you can specify that elements validation should occur as soon as that checkbox element is clicked.
328
+
329
+ ## Localization
330
+
331
+ This plugin comes with translations for English, German, French Spanish and Swedish. You can also choose to override the error
332
+ dialogs yourself. Here you can read more about [localization](http://formvalidator.net/#localization)
333
+
334
+ ## Changelog
335
+
336
+ #### 2.3.0 (unreleased)
337
+ - New translations (Polish, Romanian, Czech, Russian, Italian)
338
+ - Several improvements made to already existing translations
339
+ - "Validation help" no longer puts constraints on input names
340
+ - Improved confirmation validation
341
+ - Now possible to set `errorMessagePosition` to a callback function
342
+ - Now possible to add `data-validation-ignore` to filter out certain characters before validation
343
+ - New sanitation method `strip` that removes defined characters
344
+ - Now possible to declare attributes not prefixed with data-validation in jsconf module
345
+ - All inputs gets sanitized on page load when using sanitation module
346
+ - Allow dates to omit leading zero using `data-validation-require-leading-zero="false"`
347
+ - Module toggleDisabled now acts on value change, not only mouse click
348
+
349
+ #### 2.2.8
350
+ - The plugin is now again possible to install via bower.
351
+ - Portoguese language pack and validators
352
+ - New module used for data-sanitiation
353
+ - E-mail addresses now validated in accordance to rfc 6531
354
+ - Now possible to use $.fn.validate to programmatically validate inputs
355
+ - Hidden inputs won't get validated by default (can be overriden using option validateHiddenInputs)
356
+
357
+
358
+ #### 2.2.43
359
+ - Fixed min/max parse error in HTML5 module
360
+ - Now also supports Twitter bootstraps horizontal forms
361
+ - This plugin now also distributes a default CSS theme including success/fail icons (used on formvalidator.net)
362
+ - Email validation now won't fail if email begins with a number
363
+ - This plugin now comes with error dialogs translated to English, French, German, Spanish and English.
364
+ - New validator `letternumeric`. Validates that input consists out of any type of letter (not only alphanumeric) and/or numbers
365
+ - You can now validate image dimension and ratio
366
+ - ... and a bunch of other smaller bug fixes and improvements.
367
+
368
+ #### 2.2.0
369
+ * Now possible to define an error message for each validation rule on a certain input (issue #113)
370
+ * This plugin now serves as a html5 fallback. You can now use the native attributes to declare which type
371
+ of validation that should be applied.
372
+ * Use a template for error messages when having errorMessagePosition set to top
373
+ * Added validation of credit card number and CVV to the security module
374
+ * Event onElementValidate added
375
+ * Use the attribute data-validation-confirm to declare which input that should be confirmed when using validation=confirmation (issue #112)
376
+ * Validation "required" now supports inputs of type radio
377
+ * $.validateForm is now deprecated, use $.isValid instead
378
+ * Possible to check if form is valid programmatically without showing error messages
379
+ * Select elements can now be validated server-side
380
+ * Cleaned up dialog messages
381
+ * Various IE8 fixes
382
+ * Possible to send along parameters to the server when using server side validation
383
+ * Now possible to set your own parameter name when using server side validation
384
+ * Improved/simplified URL validation
385
+ * ... and a whole lot more small improvements
386
+
387
+ #### 2.1.47
388
+ * Incorrect error-styling when using datepicker or suggestions is now fixed
389
+ * Incorrect error-styling of select elements is now fixed
390
+ * Deprecated function $.validationSetup is now removed, use $.validate() instead
391
+ * You can now return an array with errors using the event `onValidate`
392
+ * You can now declare an element where all error messages should be placed (config.errorMessagePosition)
393
+
394
+ #### 2.1.36
395
+ * Now possible to use the native reset() function to clear error messages and error styling of the input elements
396
+
397
+ #### 2.1.34
398
+ * General improvements and bug fixes
399
+ * Added events "beforeValidation" and "validation" (see http://formvalidator.net/#configuration_callbacks for more info)
400
+
401
+ #### 2.1.27
402
+ * E-mail validation support .eu top domain
403
+ * Improvements in server validation
404
+ * Now possible to re-initiate the validation. This makes it possible to dynamically change the form and then call $.validate() again to refresh the validation (issue #59)
405
+ * Number validation now supports range
406
+
407
+ #### 2.1.15
408
+ * E-mail addresses can now contain + symbol
409
+ * Correction of the US states in validation "federatestate"
410
+ * Fixed bug in server validation
411
+
412
+ #### 2.1.09
413
+ * File validation now support multiple files
414
+ * Length validation can now be used to validate the number of uploaded files using a file input that supports multiple files
415
+ * Validation classes is no longer applied on inputs that for some reason shouldn't become validated
416
+
417
+ #### 2.1.08
418
+ * Now possible to configure the decimal separator when validating float values. Use either the
419
+ attribute *data-validation-decimal-separator* or the property *decimalSeparator* when
420
+ calling $.validate()
421
+ * $.validationSetup is renamed to $.validate. You will still be able to initiate the validation by calling
422
+ the $.validationSetup but it's considered deprecated.
423
+
424
+ #### 2.1.06
425
+ * Modules can now be loaded from remote websites
426
+
427
+ #### 2.1.05
428
+ * Fixed language bug (issue #43 on github)
429
+ * Validation on server side is now triggered by the blur event
430
+ * Now using class names that's compliant with twitter bootstrap 3.x
431
+
432
+ #### 2.1
433
+ * Code refactoring and some functions renamed
434
+ * Validator "checkbox_group" added
435
+
436
+ #### 2.0.7
437
+ * Now possible to validate file size, extension and mime type (using the file module)
438
+
439
+ #### 2.0
440
+ * [min|max]_length is removed (now merged with length validation).
441
+ * The number, int and float validation is merged together, all three variants is now validated by the number validation.
442
+ * Phone validation is moved to "sweden" module and renamed to swephone.
443
+ * The attribute to be used when defining the regular expression for custom validations is now moved to its own attribute (data-validation-regexp)
444
+ * Length validation now looks at attribute data-validation-length (eg. min5, max200, 3-12).
445
+ * The validation rule no longer needs to be prefixed with "validate_" (it's still possible to use the prefix but it's considered deprecated).
446
+ * Some validation functions is moved to modules (see the function reference over at http://formvalidator.net).
447
+ * Added function $.validationSetup() to reduce the amount of code that has to be written when initiating the form validation.
448
+
449
+
450
+ ## Credits
451
+
452
+ #### Maintainer
453
+
454
+ [Victor Jonsson](https://github.com/victorjonsson)
455
+
456
+ #### Contributors
457
+ <a href="http://stevewasiura.waztech.com" target="_blank">Steve Wasiura</a><br />
458
+ <a href="http://lagden.github.com" target="_blank">Thiago Lagden</a><br />
459
+ <a href="https://github.com/robamaton" target="_blank">Joel Sutherland</a><br />
460
+ <a href="https://github.com/mattclements" target="_blank">Matt Clements</a><br />
461
+ <a href="http://www.joshtoft.com/" target="_blank">Josh Toft</a><br/>
462
+ <a href="https://github.com/dfcplc" target="_blank">@dfcplc</a><br />
463
+ <a href="https://github.com/coffein" target="_blank">Andree Wendel</a><br />
464
+ <a href="http://www.huotmedia.com" target="_blank">Nicholas Huot</a><br />
465
+ <a href="https://github.com/Repkit" target="_blank">@repkit</a><br />
466
+ <a href="https://github.com/aL3xa" target="_blank">Alexandar Blagotic</a><br />
467
+ <a href="http://thekindof.me/" target="_blank">Yasith Fernando</a><br />
468
+ <a href="https://github.com/S0L4R1S" target="_blank">@S0L4R1S</a><br />
469
+ <a href="http://lisangan.com/">Erick Lisangan</a><br />
470
+ <a href="https://github.com/kirbs-">@kirbs</a>
471
+ <a href="https://github.com/hslee87">hslee87</a>
472
+
473
+ #### Additional credits
474
+
475
+ <a href="http://projects.scottsplayground.com/iri/" target="_blank">Scott Gonzales</a> (URL regexp)<br />
476
+ <a href="http://www.mypocket-technologies.com" target="_blank">Darren Mason</a> (Password strength meter)<br />
477
+ <a href="http://stevewasiura.waztech.com" target="_blank">Steve Wasiura</a> (Checkbox group)
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,27 @@
1
+ #encoding: utf-8
2
+
3
+ # -*- encoding: utf-8 -*-
4
+ lib = File.expand_path('../lib', __FILE__)
5
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
6
+ require 'dqs/jquery/form/validator/rails/version'
7
+
8
+ Gem::Specification.new do |gem|
9
+ gem.name = "dqs-jquery-form-validator-rails"
10
+ gem.version = Dqs::Jquery::Form::Validator::Rails::VERSION
11
+ gem.authors = ["Douglas Quintiliano dos Santos"]
12
+ gem.email = ["douglas.q.santos@gmail.com"]
13
+ gem.description = %q{Integrate the jQuery Form Validator plugin into the Rails asset pipeline}
14
+ gem.summary = %q{jQuery Form Validator is a feature rich jQuery plugin that makes it easy to validate user input while keeping your HTML markup clean from javascript code. Even though this plugin has a wide range of validation functions it's designed to require as little jQuery bandwidth as possible. This is achieved by grouping together validation functions in "modules", making it possible for the programmer to load only
15
+ those functions that's needed to validate a particular form.}
16
+ gem.homepage = "https://github.com/douglasqsantos/dqs-jquery-form-validator-rails"
17
+ gem.license = "MIT"
18
+ gem.files = `git ls-files`.split($/)
19
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
20
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
21
+ gem.require_paths = ["lib"]
22
+
23
+ gem.add_dependency "thor", "~> 0.14"
24
+ gem.add_dependency "railties", ">= 3.2", "< 5.0"
25
+
26
+ gem.add_development_dependency "bundler", "~> 1.0"
27
+ end
@@ -0,0 +1,12 @@
1
+ module Dqs
2
+ module Jquery
3
+ module Form
4
+ module Validator
5
+ module Rails
6
+ class Engine < ::Rails::Engine
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,11 @@
1
+ module Dqs
2
+ module Jquery
3
+ module Form
4
+ module Validator
5
+ module Rails
6
+ VERSION = "2.2.8"
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,13 @@
1
+ require 'dqs/jquery/form/validator/rails/version'
2
+ require 'dqs/jquery/form/validator/rails/engine' if ::Rails.version >= "3.2"
3
+
4
+ module Dqs
5
+ module Jquery
6
+ module Form
7
+ module Validator
8
+ module Rails
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1 @@
1
+ require "dqs/jquery/form/validator/rails"
@@ -0,0 +1,9 @@
1
+ /** File generated by Grunt -- do not modify
2
+ * JQUERY-FORM-VALIDATOR
3
+ *
4
+ * @version 2.3.18
5
+ * @website http://formvalidator.net/
6
+ * @author Victor Jonsson, http://victorjonsson.se
7
+ * @license MIT
8
+ */
9
+ !function(a,b){"function"==typeof define&&define.amd?define(["jquery"],function(a){return b(a)}):"object"==typeof exports?module.exports=b(require("jquery")):b(jQuery)}(this,function(a){$.formUtils.addValidator({name:"cpf",validatorFunction:function(a){var b=a.replace(/\D/g,""),c=0,d=0,e=0,f=0;if(11!==b.length||"00000000000"===b)return!1;for(i=1;i<=9;i++)c+=parseInt(b.substring(i-1,i))*(11-i);if(e=10*c%11,e>=10&&(e=0),e!==parseInt(b.substring(9,10)))return!1;for(i=1;i<=10;i++)d+=parseInt(b.substring(i-1,i))*(12-i);return f=10*d%11,f>=10&&(f=0),f===parseInt(b.substring(10,11))},errorMessage:"",errorMessageKey:"badBrazilCPFAnswer"}),$.formUtils.addValidator({name:"brphone",validatorFunction:function(a){return!!a.match(/^(\+[\d]{1,3}[\s]{0,1}){0,1}(\(){0,1}(\d){2}(\)){0,1}(\s){0,1}(\d){4,5}([-. ]){0,1}(\d){4}$/g)},errorMessage:"",errorMessageKey:"badBrazilTelephoneAnswer"}),$.formUtils.addValidator({name:"cep",validatorFunction:function(a){return!!a.match(/^(\d){5}([-. ]){0,1}(\d){3}$/g)},errorMessage:"",errorMessageKey:"badBrazilCEPAnswer"})});
@@ -0,0 +1,9 @@
1
+ /** File generated by Grunt -- do not modify
2
+ * JQUERY-FORM-VALIDATOR
3
+ *
4
+ * @version 2.3.18
5
+ * @website http://formvalidator.net/
6
+ * @author Victor Jonsson, http://victorjonsson.se
7
+ * @license MIT
8
+ */
9
+ !function(a,b){"function"==typeof define&&define.amd?define(["jquery"],function(a){return b(a)}):"object"==typeof exports?module.exports=b(require("jquery")):b(jQuery)}(this,function(a){!function(a){a.formUtils.addValidator({name:"time",validatorFunction:function(a){if(null===a.match(/^(\d{2}):(\d{2})$/))return!1;var b=parseInt(a.split(":")[0],10),c=parseInt(a.split(":")[1],10);return!(b>23||c>59)},errorMessage:"",errorMessageKey:"badTime"}),a.formUtils.addValidator({name:"birthdate",validatorFunction:function(b,c,d){var e="yyyy-mm-dd";c.valAttr("format")?e=c.valAttr("format"):"undefined"!=typeof d.dateFormat&&(e=d.dateFormat);var f=a.formUtils.parseDate(b,e);if(!f)return!1;var g=new Date,h=g.getFullYear(),i=f[0],j=f[1],k=f[2];if(i===h){var l=g.getMonth()+1;if(j===l){var m=g.getDate();return m>=k}return l>j}return h>i&&i>h-124},errorMessage:"",errorMessageKey:"badDate"})}(a)});
@@ -0,0 +1,9 @@
1
+ /** File generated by Grunt -- do not modify
2
+ * JQUERY-FORM-VALIDATOR
3
+ *
4
+ * @version 2.3.18
5
+ * @website http://formvalidator.net/
6
+ * @author Victor Jonsson, http://victorjonsson.se
7
+ * @license MIT
8
+ */
9
+ !function(a,b){"function"==typeof define&&define.amd?define(["jquery"],function(a){return b(a)}):"object"==typeof exports?module.exports=b(require("jquery")):b(jQuery)}(this,function(a){!function(a,b){"use strict";var c="undefined"!=typeof b.FileReader,d=function(b){var c=a.split((b.valAttr("allowing")||"").toLowerCase());return a.inArray("jpg",c)>-1&&-1===a.inArray("jpeg",c)?c.push("jpeg"):a.inArray("jpeg",c)>-1&&-1===a.inArray("jpg",c)&&c.push("jpg"),c},e=function(a,b,c,d){var e=d[b]||"";a.errorMessageKey="",a.errorMessage=e.replace("%s",c)},f=function(c,d,e){var f=new FileReader,g=new Image;f.readAsDataURL(c),f.onload=function(c){g.onload=function(){a(b).trigger("imageValidation",[this]),d(this)},g.onerror=function(){e()},g.src=c.target.result}};a.formUtils.addValidator({name:"mime",validatorFunction:function(b,f,g,h){if(c){var i=!0,j=f.get(0).files||[],k="",l=d(f);return j.length&&(a.each(j,function(b,c){return i=!1,k=c.type||"",a.each(l,function(a,b){return i=k.indexOf(b)>-1,i?!1:void 0}),i}),i||(a.formUtils.warn("Trying to upload a file with mime type "+k+" which is not allowed"),e(this,"wrongFileType",l.join(", "),h))),i}return a.formUtils.warn("FileReader not supported by browser, will check file extension"),a.formUtils.validators.validate_extension.validatorFunction(b,f,g,h)},errorMessage:"",errorMessageKey:"wrongFileType"}),a.formUtils.addValidator({name:"extension",validatorFunction:function(b,c,f,g){var h=!0,i=this,j=d(c);return a.each(c.get(0).files||[b],function(b,c){var d="string"==typeof c?c:c.value||c.fileName||c.name,f=d.substr(d.lastIndexOf(".")+1);return-1===a.inArray(f.toLowerCase(),j)?(h=!1,e(i,"wrongFileType",j.join(", "),g),!1):void 0}),h},errorMessage:"",errorMessageKey:"wrongFileType"}),a.formUtils.addValidator({name:"size",validatorFunction:function(b,d,f,g){var h=d.valAttr("max-size");if(!h)return a.formUtils.warn('Input "'+d.attr("name")+'" is missing data-validation-max-size attribute'),!0;if(!c)return!0;var i=a.formUtils.convertSizeNameToBytes(h),j=!0;return a.each(d.get(0).files||[],function(a,b){return j=b.size<=i}),j||e(this,"wrongFileSize",h,g),j},errorMessage:"",errorMessageKey:"wrongFileSize"}),a.formUtils.convertSizeNameToBytes=function(a){return a=a.toUpperCase(),"M"===a.substr(a.length-1,1)?1024*parseInt(a.substr(0,a.length-1),10)*1024:"MB"===a.substr(a.length-2,2)?1024*parseInt(a.substr(0,a.length-2),10)*1024:"KB"===a.substr(a.length-2,2)?1024*parseInt(a.substr(0,a.length-2),10):"B"===a.substr(a.length-1,1)?parseInt(a.substr(0,a.length-1),10):parseInt(a,10)};var g=function(){return!1};a.formUtils.checkImageDimension=function(a,b,c){var d=!1,e={width:0,height:0},f=function(a){a=a.replace("min","").replace("max","");var b=a.split("x");e.width=b[0],e.height=b[1]?b[1]:b[0]},g=!1,h=!1,i=b.split("-");return 1===i.length?0===i[0].indexOf("min")?g=i[0]:h=i[0]:(g=i[0],h=i[1]),g&&(f(g),(a.width<e.width||a.height<e.height)&&(d=c.imageTooSmall+" ("+c.min+" "+e.width+"x"+e.height+"px)")),!d&&h&&(f(h),(a.width>e.width||a.height>e.height)&&(d=a.width>e.width?c.imageTooWide+" "+e.width+"px":c.imageTooTall+" "+e.height+"px",d+=" ("+c.max+" "+e.width+"x"+e.height+"px)")),d},a.formUtils.checkImageRatio=function(a,b,c){var d=a.width/a.height,e=function(a){var b=a.replace("max","").replace("min","").split(":");return b[0]/b[1]},f=b.split("-"),g=function(a,b,c){return a>=b&&c>=a};if(1===f.length){if(d!==e(f[0]))return c.imageRatioNotAccepted}else if(2===f.length&&!g(d,e(f[0]),e(f[1])))return c.imageRatioNotAccepted;return!1},a.formUtils.addValidator({name:"dimension",validatorFunction:function(b,d,e,h,i){var j=!1;if(c){var k=d.get(0).files||[];if(j=!0,-1===d.attr("data-validation").indexOf("mime"))return alert("You should validate file type being jpg, gif or png on input "+d[0].name),!1;if(k.length>1)return alert("Validating image dimensions does not support inputs allowing multiple files"),!1;if(0===k.length)return!0;if(d.valAttr("has-valid-dim"))return!0;if(d.valAttr("has-not-valid-dim"))return this.errorMessage=h.wrongFileDim+" "+d.valAttr("has-not-valid-dim"),!1;if("keyup"===a.formUtils.eventType)return null;var l=!1;return a.formUtils.isValidatingEntireForm&&(l=!0,a.formUtils.haltValidation=!0,i.bind("submit",g).addClass("on-blur")),f(k[0],function(b){var c=!1;d.valAttr("dimension")&&(c=a.formUtils.checkImageDimension(b,d.valAttr("dimension"),h)),!c&&d.valAttr("ratio")&&(c=a.formUtils.checkImageRatio(b,d.valAttr("ratio"),h)),c?d.valAttr("has-not-valid-dim",c):d.valAttr("has-valid-dim","true"),d.valAttr("has-keyup-event")||d.valAttr("has-keyup-event","1").bind("keyup change",function(b){9!==b.keyCode&&16!==b.keyCode&&a(this).valAttr("has-not-valid-dim",!1).valAttr("has-valid-dim",!1)}),l?(a.formUtils.haltValidation=!1,i.removeClass("on-blur").get(0).onsubmit=function(){},i.unbind("submit",g),i.trigger("submit")):d.trigger("blur")},function(a){throw a}),!0}return j},errorMessage:"",errorMessageKey:""}),a(b).one("validatorsLoaded formValidationSetup",function(b,c){var d;d=c?c.find('input[type="file"]'):a('input[type="file"]'),d.filter("*[data-validation]").bind("change",function(){a(this).removeClass("error").parent().find(".form-error").remove()})})}(a,window)});