Skip to content

Commit e9defcf

Browse files
committed
location module added, suggestion functions added
1 parent 0dea224 commit e9defcf

14 files changed

+419
-52
lines changed

README.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11

2-
The goal of this project is to create a feature rich jQuery plugin used for validating form data and that
3-
keeps the HTML code clean from javascript logic. Even though the plugin has **a wide range of validation functions**
4-
it's designed to consume the least amount of bandwidth as possible (which makes it very suitable for **mobile websites**).
5-
This is achieved by grouping together functions in "modules", making it possible for the programmer
2+
**jQuery Form Validator* is a feature rich jQuery plugin that makes it easy to validate user input in HTML forsm
3+
while keeping the HTML code clean from javascript logic. Even though the plugin has **a wide range of validation functions**
4+
it's designed to consume as little bandwidth as possible (which makes it very suitable for **mobile websites**).
5+
This is achieved by grouping together validation functions in "modules", making it possible for the programmer
66
to load **only those functions that's needed** to validate a particular form.
77

88
*Usage example*
@@ -36,7 +36,6 @@ to load **only those functions that's needed** to validate a particular form.
3636
...
3737
```
3838

39-
## Features
4039
### Default validators (no module needed)
4140
* **validate_url**
4241
* **validate_email**
@@ -59,11 +58,20 @@ to load **only those functions that's needed** to validate a particular form.
5958
* **validate_time***hh:mm*
6059
* **validate_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)*
6160

61+
### Module: location
62+
* **validate_country**
63+
* **validate_federatestate**
64+
* **validate_longlat**
65+
* Suggest countries (english only)
66+
* Suggest states in the US
67+
6268
### Module: sweden
6369
* **validate_swemob***validate that the value is a swedish mobile telephone number*
6470
* **validate_swesec***validate swedish social security number*
6571
* **validate_county** - *validate that the value is an existing county in Sweden*
6672
* **validate_municipality** - *validate that the value is an existing municipality in Sweden*
73+
* Suggest county
74+
* Suggest municipality
6775

6876
### Module: ukvat
6977
* **validate_ukvatnumber**
@@ -75,6 +83,7 @@ to load **only those functions that's needed** to validate a particular form.
7583
that the validation defined in data-validation only will take place in case a value is given.
7684
* Make validation dependent on another input of type checkbox being checked by adding attribute
7785
data-validation-if-checked="name of checkbox input"
86+
* Create input suggestions with ease, no jquery-ui needed
7887

7988

8089
## Writing a custom validator

example.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99

1010
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
1111
<script type="text/javascript" src="js/formvalidator/jquery.formvalidator.js"></script>
12+
<script>
13+
$.formUtils.loadModules('date.dev, sweden.dev, security.dev, uk.dev');
14+
</script>
1215

1316
<link href="style.css?upd=1.5" type="text/css" rel="stylesheet"/>
1417

@@ -228,6 +231,11 @@ <h2>
228231
<input type="checkbox" name="disable_hours" checked="checked"/>
229232
</p>
230233

234+
<p>
235+
<strong>Country suggestion/strong>
236+
<input type="text" id="country" name="country" />
237+
</p>
238+
231239
<p>
232240
<strong>Time HH:mm</strong> <em>validate_time</em><br/>
233241
<input type="text" data-validation-if-checked="disable_hours" data-validation="validate_time" name="hours"/>
@@ -257,6 +265,10 @@ <h2>
257265
.validateOnBlur(false, validationSettings)
258266
.showHelpOnFocus();
259267

268+
$(function() {
269+
$('#country').suggestSwedishMunicipality();
270+
});
271+
260272
</script>
261273

262274
</div>

js/formvalidator/date.dev.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
* Documentation and issue tracking on Github <https://github.com/victorjonsson/jQuery-Form-Validator/>
66
*
77
* This form validation module adds validators used to validate date
8-
* and time values. The following validators will be added
8+
* and time values. The following validators will be added by
99
* this module:
1010
* - validate_time
1111
* - validate_birthdate
1212
*
1313
*
1414
* @license Dual licensed under the MIT or GPL Version 2 licenses
15-
* @version 1.9.1
15+
* @version 1.9.4
1616
*/
1717
(function($) {
1818

js/formvalidator/date.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
* Documentation and issue tracking on Github <https://github.com/victorjonsson/jQuery-Form-Validator/>
66
*
77
* This form validation module adds validators used to validate date
8-
* and time values. The following validators will be added
8+
* and time values. The following validators will be added by
99
* this module:
1010
* - validate_time
1111
* - validate_birthdate
1212
*
1313
*
1414
* @license Dual licensed under the MIT or GPL Version 2 licenses
15-
* @version 1.9.1
15+
* @version 1.9.4
1616
*/(function(a){a.formUtils.addValidator({name:"validate_time",validate:function(a){if(a.match(/^(\d{2}):(\d{2})$/)===null)return!1;var b=parseInt(a.split(":")[0],10),c=parseInt(a.split(":")[1],10);return b>24||c>59||b===24&&c>0?!1:!0},errorMessage:"",errorMessageKey:"badTime"}),a.formUtils.addValidator({name:"validate_birthdate",validate:function(b,c,d){var e="yyyy-mm-dd";c.attr("data-format")?e=c.attr("data-format"):typeof d.dateFormat!="undefined"&&(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 k<=m}return j<l}return i<h&&i>h-124},errorMessage:"",errorMessageKey:"badDate"})})(jQuery);

0 commit comments

Comments
 (0)