From 9aae372a86e7d44bb9e9c18552be3ebd268042c4 Mon Sep 17 00:00:00 2001
From: mbigatti
Date: Tue, 11 Mar 2014 14:02:53 +0100
Subject: [PATCH 1/3] First commit
---
.gitignore | 2 +
README.md | 387 +--------------
bower.json | 23 -
build | 70 ---
form-validator/date.dev.js | 81 ----
form-validator/date.js | 1 -
form-validator/file.dev.js | 148 ------
form-validator/file.js | 1 -
form-validator/form-test.html | 346 --------------
form-validator/jquery.form-validator.js | 502 ++++----------------
form-validator/jquery.form-validator.min.js | 11 -
form-validator/location.dev.js | 78 ---
form-validator/location.js | 1 -
form-validator/qunit.html | 495 -------------------
form-validator/security.dev.js | 356 --------------
form-validator/security.js | 1 -
form-validator/sweden.dev.js | 210 --------
form-validator/sweden.js | 1 -
form-validator/uk.dev.js | 85 ----
form-validator/uk.js | 1 -
formvalidator.jquery.json | 27 --
21 files changed, 107 insertions(+), 2720 deletions(-)
delete mode 100644 bower.json
delete mode 100755 build
delete mode 100644 form-validator/date.dev.js
delete mode 100644 form-validator/date.js
delete mode 100644 form-validator/file.dev.js
delete mode 100644 form-validator/file.js
delete mode 100644 form-validator/form-test.html
delete mode 100644 form-validator/jquery.form-validator.min.js
delete mode 100644 form-validator/location.dev.js
delete mode 100644 form-validator/location.js
delete mode 100644 form-validator/qunit.html
delete mode 100644 form-validator/security.dev.js
delete mode 100644 form-validator/security.js
delete mode 100644 form-validator/sweden.dev.js
delete mode 100644 form-validator/sweden.js
delete mode 100644 form-validator/uk.dev.js
delete mode 100644 form-validator/uk.js
delete mode 100644 formvalidator.jquery.json
diff --git a/.gitignore b/.gitignore
index e43b0f9..bf8f782 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,3 @@
.DS_Store
+
+_old/
\ No newline at end of file
diff --git a/README.md b/README.md
index 01c7631..44de47f 100644
--- a/README.md
+++ b/README.md
@@ -1,386 +1,21 @@
# jQuery Form Validator
-With this feature rich jQuery plugin it becomes 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 bandwidth as possible. This is achieved by grouping together validation functions
-in "modules", making it possible for the programmer to load **only those functions that's needed** to validate a
-particular form.
+This is a fork of jQuery From Validator plug-in for use with a custom UI Kit. Please refer
+to this [link](https://github.com/victorjonsson/jQuery-Form-Validator) for official and
+complete releases.
-**Form demos and full documentation is available at http://formvalidator.net/**
-
-*Usage example*
-
-```html
-
-
-
-
-```
-
-### Moving up to version 2.0
-
-So what has changed since version 1.x?
-
- * A whole bunch of validation functions have been added (see below).
- * A modular design have been introduced, which means that some validation functions is default and others is
- part of a module. This in turn lowers server and bandwidth costs.
- * You no longer need to prefix the validation rules with "validate_".
- * Error message position now defaults to "element".
- * The optional features (validateOnBlur and showHelpOnFocus) is now enabled by default.
- * The function $.validate(config) is introduced to reduce the amount of code that has to be written when initiating the form validation.
- * Demos and full documentation is now available at http://formvalidator.net/
-
-### Default validators and features (no module needed)
- * **url**
- * **email**
- * **domain** — *domain.com*
- * **number** — *float/negative/positive/range*
- * **date** — *yyyy-mm-dd (format can be customized, more information below)*
- * **alphanumeric** — *with support for defining additional characters*
- * **length** — *min/max/range*
- * **required** — *no validation except that a value has to be given*
- * **custom** — *Validate value against regexp*
- * **checkboxgroup** — *ensure at least 1 checkbox in group has been selected*
- * Show help information automatically when input is focused
- * Validate given values immediately when input looses focus.
- * Make validation optional by adding attribute data-validation-optional="true" to the element. This means
- that the validation defined in data-validation only will take place in case a value is given.
- * Make validation dependent on another input of type checkbox being checked by adding attribute
- data-validation-if-checked="name of checkbox input"
- * Create input suggestions with ease, no jquery-ui needed
-
-Read the documentation for the default features at [http://formvalidator.net/#default-validators](http://formvalidator.net/#default-validators)
-
-### Module: security
- * **spamcheck**
- * **confirmation**
- * **strength** — *Validate the strength of a password (strength strength3)*
- * **backend** — *Validate value of input on server side*
-
-Read the documentation for the security module at [http://formvalidator.net/#security-validators](http://formvalidator.net/#security-validators)
-
-### Module: date
- * **time** — *hh:mm*
- * **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)*
-
-Read the documentation for the date module at [http://formvalidator.net/#date-validators](http://formvalidator.net/#date-validators)
-
-### Module: location
- * **country**
- * **federatestate**
- * **longlat**
- * Suggest countries (english only)
- * Suggest states in the US
-
-Read the documentation for the location module at [http://formvalidator.net/#location-validators](http://formvalidator.net/#location-validators)
-
-### Module: file
- * **mime**
- * **extension**
- * **size**
-
-Read the documentation for the file module at [http://formvalidator.net/#file-validators](http://formvalidator.net/#file-validators)
-
-### Module: sweden
- * **swemob** — *validate that the value is a swedish mobile telephone number*
- * **swesec** — *validate swedish social security number*
- * **county** - *validate that the value is an existing county in Sweden*
- * **municipality** - *validate that the value is an existing municipality in Sweden*
- * Suggest county
- * Suggest municipality
-
-Read the documentation for the Swedish module at [http://formvalidator.net/#sweden-validators](http://formvalidator.net/#sweden-validators)
-
-### Module: uk
- * **ukvatnumber**
-
-Read the documentation for the UK module at [http://formvalidator.net/#uk-validators](http://formvalidator.net/#uk-validators)
-
-
-## Writing a custom validator
-You can use the function `$.formUtils.addValidator()` to add your own validation function. Here's an example of a validator
-that checks if the input contains an even number.
-
-```html
-
-
-
-
-```
-
-### Required properties passed into $.formUtils.addValidator
-
-*name* - The name of the validator, which is used in the validation attribute of the input element.
-
-*validatorFunction* - Callback function that validates the input. Should return a boolean telling if the value is considered valid or not.
-
-*errorMessageKey* - Name of language property that is used in case the value of the input is invalid.
-
-*errorMessage* - An alternative error message that is used if errorMessageKey is left with an empty value or isn't defined
-in the language object. Note that you also can use [inline error messages](http://formvalidator.net/#localization) in your form.
-
-
-The validation function takes these five arguments:
-- value — the value of the input thats being validated
-- $el — jQuery object referring to the input element being validated
-- config — Object containing the configuration of this form validation
-- language — Object with error dialogs
-- $form — jQuery object referring to the form element being validated
-
-## Creating a custom module
-
-A "module" is basically a javascript file containing one or more calls to [$.formUtils.addValidator()](#writing-a-custom-validator). The module file
-should either have the file extension *.js* (as an ordinary javascript file) or *.dev.js*.
-
-Using the file extension **.dev.js** will tell *$.formUtils.loadModules* to always append a timestamp to the end of the
-URL, so that the browser never caches the file. You should of course never use *.dev.js* on a production website.
-
-### Loading your module ###
-
-```html
-
-
-
-
-
-
-...
-```
-
-The first argument of $.formUtils.loadModules is a comma separated string with names of module files, without
-file extension (add .dev if the file name is for example mymodule.dev.js, this will insure that the browser never
-caches the javascript).
-
-The second argument is the path where the module files is located. This argument is optional, if not given
-the module files has to be located in the same directory as the core modules shipped together with this jquery plugin
-(js/form-validator/)
-
-## Show help information
-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.
-
-```html
-
- ...
-
-
-
-
-
-...
-```
-
-It's also possible to add inline error messages. If you add attribute `data-validation-error-msg` to an element the value of
-that attribute will be displayed instead of the error dialog that the validation function refers to.
-
-## Input length restriction
-```html
-
- History (50 characters left)
-
-
-
-```
-
-## Program Flow
-Form submit() event is bound to jQ func **validateForm()** when the form is submitted, it calls
-jQ func **$.formUtils.validateInput**, which calls **validatorFunction** for the specific validation
-rule assigned to the input element. If a validation fails, error messages are assigned and displayed
-as configured. If **validateOnBlur** is set to true, jQ finds all form input elements with the
-data-validation attribute and binds their onBlur event to call the function **validateInputOnBlur**.
-it calls jQ func **$.formUtils.validateInput** to validate the single input when blurred.
-
-
-## Changelog
-
-#### 2.1.47
-* Incorrect error-styling when using datepicker or suggestions is now fixed
-* Incorrect error-styling of select elements is now fixed
-* Deprecated function $.validationSetup is now removed, use $.validate() instead
-* You can now return an array with errors using the event `onValidate`
-* You can now declare an element where all error messages should be placed (config.errorMessagePosition)
-
-#### 2.1.36
-* Now possible to use the native reset() function to clear error messages and error styling of the input elements
-
-#### 2.1.34
-* General improvements and bug fixes
-* Added events "beforeValidation" and "validation" (see http://formvalidator.net/#configuration_callbacks for more info)
-
-#### 2.1.27
- * E-mail validation support .eu top domain
- * Improvements in server validation
- * 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)
- * Number validation now supports range
-
-#### 2.1.15
- * E-mail addresses can now contain + symbol
- * Correction of the US states in validation "federatestate"
- * Fixed bug in server validation
-
-#### 2.1.9
- * File validation now support multiple files
- * Length validation can now be used to validate the number of uploaded files using a file input that supports multiple files
- * Validation classes is no longer applied on inputs that for some reason shouldn't become validated
-
-#### 2.1.8
- * Now possible to configure the decimal separator when validating float values. Use either the
- attribute *data-validation-decimal-separator* or the property *decimalSeparator* when
-calling $.validate()
- * $.validationSetup is renamed to $.validate. You will still be able to initiate the validation by calling
- the $.validationSetup but it's considered deprecated.
-
-#### 2.1.6
- * Modules can now be loaded from remote website
-
-#### 2.1.5
- * Fixed language bug (issue #43 on github)
- * Validation on server side is now triggered by the blur event
- * Now using class names that's compliant with twitter bootstrap 3.x
-
-#### 2.1
- * Code refactoring and some functions renamed
- * Validator "checkbox_group" added
-
-#### 2.0.7
- * Now possible to validate file size, extension and mime type (using the file module)
-
-#### 2.0
- * [min|max]_length is removed (now merged with length validation).
- * The number, int and float validation is merged together, all three variants is now validated by the number validation.
- * Phone validation is moved to "sweden" module and renamed to swephone.
- * The attribute to be used when defining the regular expression for custom validations is now moved to its own attribute (data-validation-regexp)
- * Length validation now looks at attribute data-validation-length (eg. min5, max200, 3-12).
- * The validation rule no longer needs to be prefixed with "validate_" (it's still possible to use the prefix but it's considered deprecated).
- * Some validation functions is moved to modules (see the function reference over at http://formvalidator.net).
- * Added function $.validationSetup() to reduce the amount of code that has to be written when initiating the form validation.
+## Features
+This version:
+- removes some core validations;
+- introduce dependency on [momentjs](http://momentjs.com) for date validation;
+- removes external modules support;
+- changes some defaults;
+- changes the way error messages are rendered in HTML;
+- provide some general minor tweaks.
## Credits
#### Maintainer
[Victor Jonsson](https://github.com/victorjonsson)
-
-#### Contributors
-Steve Wasiura
-Joel Sutherland
-Matt Clements
-Josh Toft
-@dfcplc
-Andree Wendel
-Nicholas Huot
-@repkit
-Alexandar Blagotic
-Yasith Fernando
-@S0L4R1S
-Erick Lisangan
-@kirbs
-hslee87
-
-#### Additional credits
-
-Scott Gonzales (URL regexp)
-Darren Mason (Password strength meter)
-Steve Wasiura (Checkbox group)
diff --git a/bower.json b/bower.json
deleted file mode 100644
index d7c7a17..0000000
--- a/bower.json
+++ /dev/null
@@ -1,23 +0,0 @@
-{
- "name": "jQuery-Form-Validator",
- "version": "2.1.47",
- "homepage": "http://formvalidator.net/",
- "authors": [
- "victorjonsson"
- ],
- "description": "With this feature rich jQuery plugin it becomes 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 bandwidth as possible. This is achieved by grouping together validation functions in \"modules\", making it possible for the programmer to load only those functions that's needed to validate a particular form.",
- "main": "jquery.form-validator.min.js",
- "keywords": [
- "form",
- "validator",
- "jquery"
- ],
- "license": "MIT",
- "ignore": [
- "**/.*",
- "node_modules",
- "bower_components",
- "test",
- "tests"
- ]
-}
diff --git a/build b/build
deleted file mode 100755
index b5565b1..0000000
--- a/build
+++ /dev/null
@@ -1,70 +0,0 @@
-#!/usr/bin/env node
-
-var fs = require('fs'),
- sys = require('sys'),
- exec = require('child_process').exec,
- jsPath = 'form-validator/',
- mainScript = jsPath + 'jquery.form-validator.js',
- mainMinifiedScript = jsPath + 'jquery.form-validator.min.js',
- newVersion = -1;
-
-/*
- * Find out new version number
- */
-var versionParts = fs.readFileSync(mainScript, 'utf-8').split('@version ')[1].split('*/')[0].trim().split('.');
-if(versionParts.length < 3) {
- // new version number is decided in code
- newVersion = versionParts.join('.');
-}
-else {
- // Increase the last number by one
- var newSubVersion = parseInt(versionParts.splice(versionParts.length-1, 1)[0]) + 1;
- newVersion = versionParts.join('.') + '.' + newSubVersion.toString();
-}
-
-console.log('Build version: '+newVersion);
-
-/*
- * Get code docs
- */
-var documentation = fs.readFileSync(mainScript, 'utf-8').split('*/')[0]+'*/';
-var docParts = documentation.split('@version ');
-documentation = docParts[0] +'@version '+newVersion+'\n'+docParts[1].split('\n')[1];
-
-
-/**
- * Create new minified version of a file and change
- * version number
- * @param {String} path
- * @param {String} newName
- */
-function buildFile(path, newName) {
- var codeParts = fs.readFileSync(path, 'utf-8').split('@version ');
- var lastCodeParts = codeParts[1].split("\n");
- var origCode = codeParts[0] + '@version '+newVersion+ "\n" + lastCodeParts.slice(1, lastCodeParts.length).join("\n") + "";
- fs.writeFileSync(path, origCode);
- fs.writeFileSync(newName, '');
- exec('uglifyjs '+path+' >> '+newName, function (error, stdout, stderr) {
- if(stdout)
- console.log('stdout: '+stdout);
- if(error)
- console.log('error: '+error);
- if(stderr)
- console.log('stderror: '+stderr);
-
- console.log('* '+newName);
- });
-}
-
-buildFile(mainScript, mainMinifiedScript);
-fs.readdirSync(jsPath).forEach(function(f) {
- if(f.substr(-7) == '.dev.js') {
- var compressedFileName = jsPath + f.substr(0, f.length - 6) + 'js';
- buildFile(jsPath+f, compressedFileName);
- }
-});
-
-/*
- * Add docs to main script
- */
-fs.writeFileSync(mainMinifiedScript, documentation+"\n"+fs.readFileSync(mainMinifiedScript, 'utf-8'));
diff --git a/form-validator/date.dev.js b/form-validator/date.dev.js
deleted file mode 100644
index acb4010..0000000
--- a/form-validator/date.dev.js
+++ /dev/null
@@ -1,81 +0,0 @@
-/**
- * jQuery Form Validator Module: Date
- * ------------------------------------------
- * Created by Victor Jonsson
- * Documentation and issue tracking on Github
- *
- * The following validators will be added by this module:
- * - Time (HH:mmm)
- * - Birth date
- *
- * @website http://formvalidator.net/#location-validators
- * @license Dual licensed under the MIT or GPL Version 2 licenses
- * @version 2.1.47
- */
-(function($) {
-
- /*
- * Validate time hh:mm
- */
- $.formUtils.addValidator({
- name : 'time',
- validatorFunction : function(time) {
- if (time.match(/^(\d{2}):(\d{2})$/) === null) {
- return false;
- } else {
- var hours = parseInt(time.split(':')[0],10);
- var minutes = parseInt(time.split(':')[1],10);
- if( hours > 23 || minutes > 59 ) {
- return false;
- }
- }
- return true;
- },
- errorMessage : '',
- errorMessageKey: 'badTime'
- });
-
- /*
- * Is this a valid birth date
- */
- $.formUtils.addValidator({
- name : 'birthdate',
- validatorFunction : function(val, $el, conf) {
- var dateFormat = 'yyyy-mm-dd';
- if($el.valAttr('format')) {
- dateFormat = $el.valAttr('format');
- }
- else if(typeof conf.dateFormat != 'undefined') {
- dateFormat = conf.dateFormat;
- }
-
- var inputDate = $.formUtils.parseDate(val, dateFormat);
- if (!inputDate) {
- return false;
- }
-
- var d = new Date();
- var currentYear = d.getFullYear();
- var year = inputDate[0];
- var month = inputDate[1];
- var day = inputDate[2];
-
- if (year === currentYear) {
- var currentMonth = d.getMonth() + 1;
- if (month === currentMonth) {
- var currentDay = d.getDate();
- return day <= currentDay;
- }
- else {
- return month < currentMonth;
- }
- }
- else {
- return year < currentYear && year > (currentYear - 124); // we can not live for ever yet...
- }
- },
- errorMessage : '',
- errorMessageKey: 'badDate'
- });
-
-})(jQuery);
\ No newline at end of file
diff --git a/form-validator/date.js b/form-validator/date.js
deleted file mode 100644
index 07f65ce..0000000
--- a/form-validator/date.js
+++ /dev/null
@@ -1 +0,0 @@
-(function($){$.formUtils.addValidator({name:"time",validatorFunction:function(time){if(time.match(/^(\d{2}):(\d{2})$/)===null){return false}else{var hours=parseInt(time.split(":")[0],10);var minutes=parseInt(time.split(":")[1],10);if(hours>23||minutes>59){return false}}return true},errorMessage:"",errorMessageKey:"badTime"});$.formUtils.addValidator({name:"birthdate",validatorFunction:function(val,$el,conf){var dateFormat="yyyy-mm-dd";if($el.valAttr("format")){dateFormat=$el.valAttr("format")}else if(typeof conf.dateFormat!="undefined"){dateFormat=conf.dateFormat}var inputDate=$.formUtils.parseDate(val,dateFormat);if(!inputDate){return false}var d=new Date;var currentYear=d.getFullYear();var year=inputDate[0];var month=inputDate[1];var day=inputDate[2];if(year===currentYear){var currentMonth=d.getMonth()+1;if(month===currentMonth){var currentDay=d.getDate();return day<=currentDay}else{return monthcurrentYear-124}},errorMessage:"",errorMessageKey:"badDate"})})(jQuery);
\ No newline at end of file
diff --git a/form-validator/file.dev.js b/form-validator/file.dev.js
deleted file mode 100644
index 2a876e4..0000000
--- a/form-validator/file.dev.js
+++ /dev/null
@@ -1,148 +0,0 @@
-/**
- * jQuery Form Validator Module: File
- * ------------------------------------------
- * Created by Victor Jonsson
- *
- * The following validators will be added by this module:
- * - mime type
- * - file size
- * - file extension
- *
- * @website http://formvalidator.net/
- * @license Dual licensed under the MIT or GPL Version 2 licenses
- * @version 2.1.47
- */
-(function($, window) {
-
- var SUPPORTS_FILE_READER = typeof window.FileReader != 'undefined',
-
- /**
- * @return {Array}
- */
- _getTypes = function($input) {
- var allowedTypes = $.split( ($input.valAttr('allowing') || '').toLowerCase() );
-
- if( $.inArray('jpg', allowedTypes) > -1 && $.inArray('jpeg', allowedTypes) == -1)
- allowedTypes.push('jpeg');
- else if( $.inArray('jpeg', allowedTypes) > -1 && $.inArray('jpg', allowedTypes) == -1)
- allowedTypes.push('jpg');
- return allowedTypes;
- };
-
- /*
- * Validate mime type (falls back on validate_extension in older browsers)
- */
- $.formUtils.addValidator({
- name : 'mime',
- validatorFunction : function(str, $input) {
- var files = $input.get(0).files || [];
-
- if( SUPPORTS_FILE_READER ) {
- var valid = true,
- mime = '',
- allowedTypes = _getTypes($input);
-
- $.each(files, function(i, file) {
- valid = false;
- mime = file.type || '';
- $.each(allowedTypes, function(j, type) {
- valid = mime.indexOf(type) > -1;
- if( valid ) {
- return false;
- }
- });
- return valid;
- });
- return valid;
-
- } else {
- return $.formUtils.validators.extension.validatorFunction(str, $input);
- }
- },
- errorMessage : 'The file you are trying to upload is of wrong type',
- errorMessageKey: 'wrongFileType'
- });
-
- /**
- * Validate file extension
- */
- $.formUtils.addValidator({
- name : 'extension',
- validatorFunction : function(value, $input) {
- var valid = true,
- types = _getTypes($input);
-
- $.each($input.get(0).files || [], function(i, file) {
- var val = file.value,
- ext = val.substr( val.lastIndexOf('.')+1 );
- if( $.inArray(ext.toLowerCase(), types) == -1 ) {
- valid = false;
- return false;
- }
- });
- return valid;
- },
- errorMessage : 'The file you are trying to upload is of wrong type',
- errorMessageKey: 'wrongFileType'
- });
-
- /**
- * Validate file size
- */
- $.formUtils.addValidator({
- name : 'size',
- validatorFunction : function(val, $input) {
- var maxSize = $input.valAttr('max-size');
- if( !maxSize ) {
- console.log('Input "'+$input.attr('name')+'" is missing data-validation-max-size attribute');
- return true;
- } else if( !SUPPORTS_FILE_READER ) {
- return true; // no fallback available
- }
-
- var maxBytes = $.formUtils.convertSizeNameToBytes(maxSize),
- valid = true;
- $.each($input.get(0).files || [], function(i, file) {
- valid = file.size <= maxBytes;
- return valid;
- });
- return valid;
- },
- errorMessage : 'The file you are trying to upload is too large',
- errorMessageKey: 'wrongFileSize'
- });
-
- /**
- * Make this function accessible via formUtils for unit tests
- * @param {String} sizeName
- * @return {Number}
- */
- $.formUtils.convertSizeNameToBytes = function(sizeName) {
- sizeName = sizeName.toUpperCase();
- if( sizeName.substr(sizeName.length-1, 1) == 'M' ) {
- return parseInt(sizeName.substr(0, sizeName.length-1), 10) * 1024 * 1024;
- } else if( sizeName.substr(sizeName.length-2, 2) == 'MB' ) {
- return parseInt(sizeName.substr(0, sizeName.length-2), 10) * 1024 * 1024;
- } else if( sizeName.substr(sizeName.length-2, 2) == 'KB' ) {
- return parseInt(sizeName.substr(0, sizeName.length-2), 10) * 1024;
- } else if( sizeName.substr(sizeName.length-1, 1) == 'B' ) {
- return parseInt(sizeName.substr(0, sizeName.length-1), 10);
- } else {
- return parseInt(sizeName, 10);
- }
- };
-
- /*
- * This event listener will remove error messages for file
- * inputs when file changes
- */
- $.formUtils.on('load', function() {
- $('input[type="file"]').filter('*[data-validation]').bind('change', function() {
- $(this)
- .removeClass('error')
- .parent()
- .find('.form-error').remove();
- });
- });
-
-})(jQuery, window);
\ No newline at end of file
diff --git a/form-validator/file.js b/form-validator/file.js
deleted file mode 100644
index bbcb712..0000000
--- a/form-validator/file.js
+++ /dev/null
@@ -1 +0,0 @@
-(function($,window){var SUPPORTS_FILE_READER=typeof window.FileReader!="undefined",_getTypes=function($input){var allowedTypes=$.split(($input.valAttr("allowing")||"").toLowerCase());if($.inArray("jpg",allowedTypes)>-1&&$.inArray("jpeg",allowedTypes)==-1)allowedTypes.push("jpeg");else if($.inArray("jpeg",allowedTypes)>-1&&$.inArray("jpg",allowedTypes)==-1)allowedTypes.push("jpg");return allowedTypes};$.formUtils.addValidator({name:"mime",validatorFunction:function(str,$input){var files=$input.get(0).files||[];if(SUPPORTS_FILE_READER){var valid=true,mime="",allowedTypes=_getTypes($input);$.each(files,function(i,file){valid=false;mime=file.type||"";$.each(allowedTypes,function(j,type){valid=mime.indexOf(type)>-1;if(valid){return false}});return valid});return valid}else{return $.formUtils.validators.extension.validatorFunction(str,$input)}},errorMessage:"The file you are trying to upload is of wrong type",errorMessageKey:"wrongFileType"});$.formUtils.addValidator({name:"extension",validatorFunction:function(value,$input){var valid=true,types=_getTypes($input);$.each($input.get(0).files||[],function(i,file){var val=file.value,ext=val.substr(val.lastIndexOf(".")+1);if($.inArray(ext.toLowerCase(),types)==-1){valid=false;return false}});return valid},errorMessage:"The file you are trying to upload is of wrong type",errorMessageKey:"wrongFileType"});$.formUtils.addValidator({name:"size",validatorFunction:function(val,$input){var maxSize=$input.valAttr("max-size");if(!maxSize){console.log('Input "'+$input.attr("name")+'" is missing data-validation-max-size attribute');return true}else if(!SUPPORTS_FILE_READER){return true}var maxBytes=$.formUtils.convertSizeNameToBytes(maxSize),valid=true;$.each($input.get(0).files||[],function(i,file){valid=file.size<=maxBytes;return valid});return valid},errorMessage:"The file you are trying to upload is too large",errorMessageKey:"wrongFileSize"});$.formUtils.convertSizeNameToBytes=function(sizeName){sizeName=sizeName.toUpperCase();if(sizeName.substr(sizeName.length-1,1)=="M"){return parseInt(sizeName.substr(0,sizeName.length-1),10)*1024*1024}else if(sizeName.substr(sizeName.length-2,2)=="MB"){return parseInt(sizeName.substr(0,sizeName.length-2),10)*1024*1024}else if(sizeName.substr(sizeName.length-2,2)=="KB"){return parseInt(sizeName.substr(0,sizeName.length-2),10)*1024}else if(sizeName.substr(sizeName.length-1,1)=="B"){return parseInt(sizeName.substr(0,sizeName.length-1),10)}else{return parseInt(sizeName,10)}};$.formUtils.on("load",function(){$('input[type="file"]').filter("*[data-validation]").bind("change",function(){$(this).removeClass("error").parent().find(".form-error").remove()})})})(jQuery,window);
\ No newline at end of file
diff --git a/form-validator/form-test.html b/form-validator/form-test.html
deleted file mode 100644
index 77f8855..0000000
--- a/form-validator/form-test.html
+++ /dev/null
@@ -1,346 +0,0 @@
-
-
-
-
- Form Test
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/form-validator/jquery.form-validator.js b/form-validator/jquery.form-validator.js
index eeb5457..3b44846 100644
--- a/form-validator/jquery.form-validator.js
+++ b/form-validator/jquery.form-validator.js
@@ -17,11 +17,8 @@
.removeClass('valid')
.parent()
.addClass('has-error')
- .removeClass('has-success'); // twitter bs
- if(conf.borderColorOnError !== '') {
- $elem.css('border-color', conf.borderColorOnError);
- }
+ $elem.parent().find('i').addClass(conf.errorElementClass);
},
_removeErrorStyle = function($elem, conf) {
$elem.each(function() {
@@ -29,52 +26,68 @@
$(this)
.removeClass('valid')
.removeClass(conf.errorElementClass)
- .css('border-color', '')
+ .css('border-color', '');
+ /*
.parent()
.removeClass('has-error')
- .removeClass('has-success')
+ .removeClass('has-success');
.find('.'+conf.errorMessageClass) // remove inline error message
.remove();
+ */
+
+ var $pp = $(this).data('muikit-popover');
+ if (typeof $pp !== 'undefined') {
+ $pp.remove();
+ }
+ $(this).parent().find('i').removeClass(conf.errorElementClass);
});
},
_setInlineErrorMessage = function($input, mess, conf, $messageContainer) {
- var custom = _getInlineErrorElement($input);
- if( custom ) {
- custom.innerHTML = mess;
- }
- else if( typeof $messageContainer == 'object' ) {
- var $found = false;
- $messageContainer.find('.'+conf.errorMessageClass).each(function() {
- if( this.inputReferer == $input[0] ) {
- $found = $(this);
- return false;
- }
- });
- if( $found ) {
- if( !mess ) {
- $found.remove();
- } else {
- $found.html(mess);
- }
- } else {
- var $mess = $(''+mess+'
');
- $mess[0].inputReferer = $input[0];
- $messageContainer.prepend($mess);
- }
- }
- else {
- var $mess = $input.parent().find('.'+conf.errorMessageClass+'.help-block');
- if( $mess.length == 0 ) {
- $mess = $(' ').addClass('help-block').addClass(conf.errorMessageClass);
- $mess.appendTo($input.parent());
- }
- $mess.html(mess);
- }
- },
- _getInlineErrorElement = function($input, conf) {
- return document.getElementById($input.attr('name')+'_err_msg');
+ if (mess.length == 0) {
+ return;
+ }
+
+ var $pp = $(this).data('muikit-popover');
+ if (typeof $pp === 'undefined') {
+ // show error popover
+ var divId = $input.attr('id') + "_error_popover";
+
+ var html = '' +
+ '
' +
+ ' ' +
+ mess +
+ //' ' + mess + ' ' +
+ '
'+
+ '
';
+
+ var offset = $input.position();
+ if ($input.parent().hasClass('muik-combobox')) {
+ $input.parent().parent().append(html);
+ } else {
+ $input.parent().append(html);
+ }
+
+ var $popover = $('#' + divId);
+ $input.data('muikit-popover', $popover);
+
+ var PADDING_LEFT = 20;
+ var w = Math.min($popover.outerWidth(), $input.outerWidth() - PADDING_LEFT);
+ $popover.find('div').css('max-width', w);
+
+ var e = {};
+ e.pageX = offset.left + $input.outerWidth() - w;
+ e.pageY = offset.top - $popover.outerHeight() - 12;
+
+ $popover.positionInScreen(e);
+ $popover.find('div').css('opacity', 1);
+
+ } else {
+ $pp.find('span').html(mess);
+
+ }
};
+
/**
* Assigns validateInputOnBlur function to elements blur event
*
@@ -147,7 +160,6 @@
$help = $(' ')
.addClass(className)
.addClass('help')
- .addClass('help-block') // twitter bs
.text(help)
.hide();
@@ -205,7 +217,6 @@
}
language = $.extend({}, $.formUtils.LANG, language || {});
- _removeErrorStyle(this, conf);
var $elem = this,
$form = $elem.closest("form"),
@@ -221,10 +232,9 @@
$elem.trigger('validation', [validation===null ? null : validation===true]);
if(validation === true) {
- $elem
- .addClass('valid')
- .parent()
- .addClass('has-success'); // twitter bs
+ $elem.addClass('valid');
+ _removeErrorStyle(this, conf);
+
} else if(validation !== null) {
_applyErrorStyle($elem, conf);
@@ -315,7 +325,7 @@
};
// Reset style and remove error class
- $form.find('.'+conf.errorMessageClass+'.alert').remove();
+ //$form.find('.'+conf.errorMessageClass+'.alert').remove();
_removeErrorStyle($form.find('.'+conf.errorElementClass+',.valid'), conf);
// Validate element values
@@ -336,12 +346,11 @@
if(validation !== true) {
addErrorMessage(validation, $elem);
+
} else {
$elem
.valAttr('current-error', false)
- .addClass('valid')
- .parent()
- .addClass('has-success');
+ .addClass('valid');
}
}
@@ -374,7 +383,9 @@
});
// using div instead of P gives better control of css display properties
- $form.children().eq(0).before('' + messages + '
');
+ //$form.children().eq(0).before('' + messages + '
');
+
+ // FIXME
}
// Display error message below input field or in defined container
@@ -472,8 +483,6 @@
validateOnBlur : true,
showHelpOnFocus : true,
addSuggestions : true,
- modules : '',
- onModulesLoaded : null,
language : false,
onSuccess : false,
onError : false
@@ -500,12 +509,6 @@
// Validate when submitted
$form.bind('submit.validation', function() {
var $form = $(this);
- if($.formUtils.isLoadingModules) {
- setTimeout(function() {
- $form.trigger('submit.validation');
- }, 200);
- return false;
- }
var valid = $form.validateForm(conf.language, conf);
if( valid && typeof conf.onSuccess == 'function') {
var callbackResponse = conf.onSuccess($form);
@@ -520,7 +523,7 @@
})
.bind('reset.validation', function() {
// remove messages
- $(this).find('.'+conf.errorMessageClass+'.alert').remove();
+ //$(this).find('.'+conf.errorMessageClass+'.alert').remove();
_removeErrorStyle($(this).find('.'+conf.errorElementClass+',.valid'), conf);
})
.addClass('has-validation-callback');
@@ -539,15 +542,6 @@
}
});
-
- if( conf.modules != '' ) {
- if( typeof conf.onModulesLoaded == 'function' ) {
- $.formUtils.on('load', function() {
- conf.onModulesLoaded();
- });
- }
- $.formUtils.loadModules(conf.modules);
- }
};
/**
@@ -560,17 +554,18 @@
*/
defaultConfig : function() {
return {
- ignore : [], // Names of inputs not to be validated even though node attribute containing the validation rules tells us to
- errorElementClass : 'error', // Class that will be put on elements which value is invalid
- borderColorOnError : 'red', // Border color of elements which value is invalid, empty string to not change border color
- errorMessageClass : 'form-error', // class name of div containing error messages when validation fails
- validationRuleAttribute : 'data-validation', // name of the attribute holding the validation rules
- validationErrorMsgAttribute : 'data-validation-error-msg', // define custom err msg inline with element
- errorMessagePosition : 'element', // Can be either "top" or "element"
+ ignore : [], // Names of inputs not to be validated even though node attribute containing the validation rules tells us to
+ errorElementClass : 'critical', // Class that will be put on elements which value is invalid
+ validationRuleAttribute :
+ 'data-validation', // name of the attribute holding the validation rules
+ validationErrorMsgAttribute :
+ 'data-validation-error-msg', // define custom err msg inline with element
+ errorMessagePosition : 'element', // Can be either "top" or "element"
scrollToTopOnError : true,
- dateFormat : 'yyyy-mm-dd',
- addValidClassOnAll : false, // whether or not to apply class="valid" even if the input wasn't validated
- decimalSeparator : '.'
+ addValidClassOnAll : false, // whether or not to apply class="valid" even if the input wasn't validated
+ decimalSeparator : ',',
+ showHelpOnFocus : false,
+ addSuggestions : false
}
},
@@ -631,127 +626,6 @@
});
},
- /**
- * @ {Boolean}
- */
- isLoadingModules : false,
-
- loadedModules : {},
-
- /**
- * @example
- * $.formUtils.loadModules('date, security.dev');
- *
- * Will load the scripts date.js and security.dev.js from the
- * directory where this script resides. If you want to load
- * the modules from another directory you can use the
- * path argument.
- *
- * The script will be cached by the browser unless the module
- * name ends with .dev
- *
- * @param {String} modules - Comma separated string with module file names (no directory nor file extension)
- * @param {String} [path] - Optional, path where the module files is located if their not in the same directory as the core modules
- * @param {Boolean} [fireEvent] - Optional, whether or not to fire event 'load' when modules finished loading
- */
- loadModules : function(modules, path, fireEvent) {
-
- if( fireEvent === undefined )
- fireEvent = true;
-
- if( $.formUtils.isLoadingModules ) {
- setTimeout(function() {
- $.formUtils.loadModules(modules, path, fireEvent);
- });
- return;
- }
-
- var hasLoadedAnyModule = false,
- loadModuleScripts = function(modules, path) {
- var moduleList = $.split(modules),
- numModules = moduleList.length,
- moduleLoadedCallback = function() {
- numModules--;
- if( numModules == 0 ) {
- $.formUtils.isLoadingModules = false;
- if( fireEvent && hasLoadedAnyModule ) {
- $.formUtils.trigger('load', path);
- }
- }
- };
-
- if( numModules > 0 ) {
- $.formUtils.isLoadingModules = true;
- }
-
- var cacheSuffix = '?__='+( new Date().getTime() ),
- appendToElement = document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0];
-
- $.each(moduleList, function(i, modName) {
- modName = $.trim(modName);
- if( modName.length == 0 ) {
- moduleLoadedCallback();
- }
- else {
- var scriptUrl = path + modName + (modName.substr(-3) == '.js' ? '':'.js'),
- script = document.createElement('SCRIPT');
-
- if( scriptUrl in $.formUtils.loadedModules ) {
- // already loaded
- moduleLoadedCallback();
- }
- else {
-
- // Remember that this script is loaded
- $.formUtils.loadedModules[scriptUrl] = 1;
- hasLoadedAnyModule = true;
-
- // Load the script
- script.type = 'text/javascript';
- script.onload = moduleLoadedCallback;
- script.src = scriptUrl + ( scriptUrl.substr(-7) == '.dev.js' ? cacheSuffix:'' );
- script.onreadystatechange = function() {
- // IE 7 fix
- if( this.readyState == 'complete' ) {
- moduleLoadedCallback();
- }
- };
- appendToElement.appendChild( script );
- }
- }
- });
- };
-
- if( path ) {
- loadModuleScripts(modules, path);
- } else {
- var findScriptPathAndLoadModules = function() {
- var foundPath = false;
- $('script').each(function() {
- if( this.src ) {
- var scriptName = this.src.substr(this.src.lastIndexOf('/')+1, this.src.length);
- if(scriptName.indexOf('jquery.form-validator.js') > -1 || scriptName.indexOf('jquery.form-validator.min.js') > -1) {
- foundPath = this.src.substr(0, this.src.lastIndexOf('/')) + '/';
- if( foundPath == '/' )
- foundPath = '';
- return false;
- }
- }
- });
-
- if( foundPath !== false) {
- loadModuleScripts(modules, foundPath);
- return true;
- }
- return false;
- };
-
- if( !findScriptPathAndLoadModules() ) {
- $(findScriptPathAndLoadModules);
- }
- }
- },
-
/**
* Validate the value of given element according to the validation rules
* found in the attribute data-validation. Will return true if valid,
@@ -857,79 +731,6 @@
}
},
- /**
- * Is it a correct date according to given dateFormat. Will return false if not, otherwise
- * an array 0=>year 1=>month 2=>day
- *
- * @param {String} val
- * @param {String} dateFormat
- * @return {Array}|{Boolean}
- */
- parseDate : function(val, dateFormat) {
- var divider = dateFormat.replace(/[a-zA-Z]/gi, '').substring(0,1),
- regexp = '^',
- formatParts = dateFormat.split(divider),
- matches, day, month, year;
-
- $.each(formatParts, function(i, part) {
- regexp += (i > 0 ? '\\'+divider:'') + '(\\d{'+part.length+'})';
- });
-
- regexp += '$';
-
- matches = val.match(new RegExp(regexp));
- if (matches === null) {
- return false;
- }
-
- var findDateUnit = function(unit, formatParts, matches) {
- for(var i=0; i < formatParts.length; i++) {
- if(formatParts[i].substring(0,1) === unit) {
- return $.formUtils.parseDateInt(matches[i+1]);
- }
- }
- return -1;
- };
-
- month = findDateUnit('m', formatParts, matches);
- day = findDateUnit('d', formatParts, matches);
- year = findDateUnit('y', formatParts, matches);
-
- if ((month === 2 && day > 28 && (year % 4 !== 0 || year % 100 === 0 && year % 400 !== 0))
- || (month === 2 && day > 29 && (year % 4 === 0 || year % 100 !== 0 && year % 400 === 0))
- || month > 12 || month === 0) {
- return false;
- }
- if ((this.isShortMonth(month) && day > 30) || (!this.isShortMonth(month) && day > 31) || day === 0) {
- return false;
- }
-
- return [year, month, day];
- },
-
- /**
- * skum fix. är talet 05 eller lägre ger parseInt rätt int annars får man 0 när man kör parseInt?
- *
- * @param {String} val
- * @param {Number}
- */
- parseDateInt : function(val) {
- if (val.indexOf('0') === 0) {
- val = val.replace('0', '');
- }
- return parseInt(val,10);
- },
-
- /**
- * Has month only 30 days?
- *
- * @param {Number} m
- * @return {Boolean}
- */
- isShortMonth : function(m) {
- return (m % 2 === 0 && m < 7) || (m % 2 !== 0 && m > 7);
- },
-
/**
* Restrict input length
*
@@ -1224,21 +1025,20 @@
*/
LANG : {
errorTitle : 'Form submission failed!',
- requiredFields : 'You have not answered all required fields',
+ requiredFields : 'Campo obbligatorio',
badTime : 'You have not given a correct time',
badEmail : 'You have not given a correct e-mail address',
badTelephone : 'You have not given a correct phone number',
badSecurityAnswer : 'You have not given a correct answer to the security question',
- badDate : 'You have not given a correct date',
+ badDate : 'Data non valida',
lengthBadStart : 'You must give an answer between ',
lengthBadEnd : ' characters',
lengthTooLongStart : 'You have given an answer longer than ',
lengthTooShortStart : 'You have given an answer shorter than ',
notConfirmed : 'Values could not be confirmed',
- badDomain : 'Incorrect domain value',
badUrl : 'The answer you gave was not a correct URL',
badCustomVal : 'You gave an incorrect answer',
- badInt : 'The answer you gave was not a correct number',
+ badInt : 'Numero non valido',
badSecurityNumber : 'Your social security number was incorrect',
badUKVatAnswer : 'Incorrect UK VAT Number',
badStrength : 'The password isn\'t strong enough',
@@ -1280,108 +1080,6 @@
errorMessageKey : 'badEmail'
});
- /*
- * Validate domain name
- */
- $.formUtils.addValidator({
- name : 'domain',
- validatorFunction : function(val, $input) {
-
- var topDomains = ['.ac', '.ad', '.ae', '.aero', '.af', '.ag', '.ai', '.al', '.am', '.an', '.ao',
- '.aq', '.ar', '.arpa', '.as', '.asia', '.at', '.au', '.aw', '.ax', '.az', '.ba', '.bb',
- '.bd', '.be', '.bf', '.bg', '.bh', '.bi', '.bike', '.biz', '.bj', '.bm', '.bn', '.bo',
- '.br', '.bs', '.bt', '.bv', '.bw', '.by', '.bz', '.ca', '.camera', '.cat', '.cc', '.cd',
- '.cf', '.cg', '.ch', '.ci', '.ck', '.cl', '.clothing', '.cm', '.cn', '.co', '.com',
- '.construction', '.contractors', '.coop', '.cr', '.cu', '.cv', '.cw', '.cx', '.cy', '.cz',
- '.de', '.diamonds', '.directory', '.dj', '.dk', '.dm', '.do', '.dz', '.ec', '.edu', '.ee',
- '.eg', '.enterprises', '.equipment', '.er', '.es', '.estate', '.et', '.eu', '.fi', '.fj',
- '.fk', '.fm', '.fo', '.fr', '.ga', '.gallery', '.gb', '.gd', '.ge', '.gf', '.gg', '.gh',
- '.gi', '.gl', '.gm', '.gn', '.gov', '.gp', '.gq', '.gr', '.graphics', '.gs', '.gt', '.gu',
- '.guru', '.gw', '.gy', '.hk', '.hm', '.hn', '.holdings', '.hr', '.ht', '.hu', '.id', '.ie',
- '.il', '.im', '.in', '.info', '.int', '.io', '.iq', '.ir', '.is', '.it', '.je', '.jm', '.jo',
- '.jobs', '.jp', '.ke', '.kg', '.kh', '.ki', '.kitchen', '.km', '.kn', '.kp', '.kr', '.kw',
- '.ky', '.kz', '.la', '.land', '.lb', '.lc', '.li', '.lighting', '.lk', '.lr', '.ls', '.lt',
- '.lu', '.lv', '.ly', '.ma', '.mc', '.md', '.me', '.menu', '.mg', '.mh', '.mil', '.mk', '.ml',
- '.mm', '.mn', '.mo', '.mobi', '.mp', '.mq', '.mr', '.ms', '.mt', '.mu', '.museum', '.mv',
- '.mw', '.mx', '.my', '.mz', '.na', '.name', '.nc', '.ne', '.net', '.nf', '.ng', '.ni',
- '.nl', '.no', '.np', '.nr', '.nu', '.nz', '.om', '.org', '.pa', '.pe', '.pf', '.pg', '.ph',
- '.photography', '.pk', '.pl', '.plumbing', '.pm', '.pn', '.post', '.pr', '.pro', '.ps', '.pt',
- '.pw', '.py', '.qa', '.re', '.ro', '.rs', '.ru', '.rw', '.sa', '.sb', '.sc', '.sd', '.se',
- '.sexy', '.sg', '.sh', '.si', '.singles', '.sj', '.sk', '.sl', '.sm', '.sn', '.so', '.sr',
- '.st', '.su', '.sv', '.sx', '.sy', '.sz', '.tattoo', '.tc', '.td', '.technology', '.tel', '.tf',
- '.tg', '.th', '.tips', '.tj', '.tk', '.tl', '.tm', '.tn', '.to', '.today', '.tp', '.tr', '.travel',
- '.tt', '.tv', '.tw', '.tz', '.ua', '.ug', '.uk', '.uno', '.us', '.uy', '.uz', '.va', '.vc', '.ve',
- '.ventures', '.vg', '.vi', '.vn', '.voyage', '.vu', '.wf', '.ws', '.xn--3e0b707e', '.xn--45brj9c',
- '.xn--80ao21a', '.xn--80asehdb', '.xn--80aswg', '.xn--90a3ac', '.xn--clchc0ea0b2g2a9gcd', '.xn--fiqs8s',
- '.xn--fiqz9s', '.xn--fpcrj9c3d', '.xn--fzc2c9e2c', '.xn--gecrj9c', '.xn--h2brj9c', '.xn--j1amh',
- '.xn--j6w193g', '.xn--kprw13d', '.xn--kpry57d', '.xn--l1acc', '.xn--lgbbat1ad8j', '.xn--mgb9awbf',
- '.xn--mgba3a4f16a', '.xn--mgbaam7a8h', '.xn--mgbayh7gpa', '.xn--mgbbh1a71e', '.xn--mgbc0a9azcg',
- '.xn--mgberp4a5d4ar', '.xn--mgbx4cd0ab', '.xn--ngbc5azd', '.xn--o3cw4h', '.xn--ogbpf8fl', '.xn--p1ai',
- '.xn--pgbs0dh', '.xn--q9jyb4c', '.xn--s9brj9c', '.xn--unup4y', '.xn--wgbh1c', '.xn--wgbl6a',
- '.xn--xkc2al3hye2a', '.xn--xkc2dl3a5ee0h', '.xn--yfro4i67o', '.xn--ygbi2ammx', '.xxx', '.ye',
- '.yt', '.za', '.zm', '.zw'],
-
- ukTopDomains = ['co', 'me', 'ac', 'gov', 'judiciary','ltd', 'mod', 'net', 'nhs', 'nic',
- 'org', 'parliament', 'plc', 'police', 'sch', 'bl', 'british-library', 'jet','nls'],
-
- dot = val.lastIndexOf('.'),
- domain = val.substring(0, dot),
- ext = val.substring(dot, val.length),
- hasTopDomain = false;
-
- for (var i = 0; i < topDomains.length; i++) {
- if (topDomains[i] === ext) {
- if(ext==='.uk') {
- //Run Extra Checks for UK Domain Names
- var domainParts = val.split('.');
- var tld2 = domainParts[domainParts.length-2];
- for(var j = 0; j < ukTopDomains.length; j++) {
- if(ukTopDomains[j] === tld2) {
- hasTopDomain = true;
- break;
- }
- }
-
- if(hasTopDomain)
- break;
-
- } else {
- hasTopDomain = true;
- break;
- }
- }
- }
-
- if (!hasTopDomain) {
- return false;
- } else if (dot < 2 || dot > 57) {
- return false;
- } else {
- var firstChar = domain.substring(0, 1),
- lastChar = domain.substring(domain.length - 1, domain.length);
-
- if (firstChar === '-' || firstChar === '.' || lastChar === '-' || lastChar === '.') {
- return false;
- }
- if (domain.split('.').length > 3 || domain.split('..').length > 1) {
- return false;
- }
- if (domain.replace(/[-\da-z\.]/g, '') !== '') {
- return false;
- }
- }
-
- // It's valid, lets update input with trimmed value perhaps??
- if(typeof $input !== 'undefined') {
- $input.val(val);
- }
-
- return true;
- },
- errorMessage : '',
- errorMessageKey: 'badDomain'
- });
-
/*
* Validate required
*/
@@ -1441,30 +1139,6 @@
errorMessageKey: ''
});
- /*
- * Validate url
- */
- $.formUtils.addValidator({
- name : 'url',
- validatorFunction : function(url) {
- // written by Scott Gonzalez: http://projects.scottsplayground.com/iri/
- // - Victor Jonsson added support for arrays in the url ?arg[]=sdfsdf
- // - General improvements made by Stéphane Moureau
- var urlFilter = /^(https?|ftp):\/\/((((\w|-|\.|~|[\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])(\w|-|\.|~|[\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])(\w|-|\.|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/(((\w|-|\.|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/((\w|-|\.|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|\[|\]|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#(((\w|-|\.|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i;
- if( urlFilter.test(url) ) {
- var domain = url.split('://')[1];
- var domainSlashPos = domain.indexOf('/');
- if(domainSlashPos > -1)
- domain = domain.substr(0, domainSlashPos);
-
- return $.formUtils.validators.validate_domain.validatorFunction(domain); // todo: add support for IP-addresses
- }
- return false;
- },
- errorMessage : '',
- errorMessageKey: 'badUrl'
- });
-
/*
* Validate number (floating or integer)
*/
@@ -1495,7 +1169,10 @@
// Fix for checking range with floats using ,
val = val.replace(',', '.');
}
-
+
+ if(allowing.indexOf('integer') > -1 && val.indexOf(decimalSeparator) != -1) {
+ return false;
+ }
if(allowing.indexOf('number') > -1 && val.replace(/[0-9]/g, '') === '' && (!allowsRange || (val >= begin && val <= end)) ) {
return true;
}
@@ -1558,15 +1235,24 @@
$.formUtils.addValidator({
name : 'date',
validatorFunction : function(date, $el, conf) {
- var dateFormat = 'yyyy-mm-dd';
+ var dateFormat = 'DD/MM/YYYY';
if($el.valAttr('format')) {
dateFormat = $el.valAttr('format');
}
else if( conf.dateFormat ) {
dateFormat = conf.dateFormat;
}
-
- return $.formUtils.parseDate(date, dateFormat) !== false;
+
+ var allowsEmpty = false;
+ if($el.valAttr('allows-empty')) {
+ allowsEmpty = $el.valAttr('allows-empty');
+ }
+
+ if (date.trim().length == 0 && allowsEmpty) {
+ return true;
+ }
+
+ return moment(date, dateFormat).isValid();
},
errorMessage : '',
errorMessageKey: 'badDate'
diff --git a/form-validator/jquery.form-validator.min.js b/form-validator/jquery.form-validator.min.js
deleted file mode 100644
index 79df521..0000000
--- a/form-validator/jquery.form-validator.min.js
+++ /dev/null
@@ -1,11 +0,0 @@
-/**
-* jQuery Form Validator
-* ------------------------------------------
-* Created by Victor Jonsson
-*
-* @website http://formvalidator.net/
-* @license Dual licensed under the MIT or GPL Version 2 licenses
-* @version 2.1.47
-*/
-(function($){"use strict";var _applyErrorStyle=function($elem,conf){$elem.addClass(conf.errorElementClass).removeClass("valid").parent().addClass("has-error").removeClass("has-success");if(conf.borderColorOnError!==""){$elem.css("border-color",conf.borderColorOnError)}},_removeErrorStyle=function($elem,conf){$elem.each(function(){_setInlineErrorMessage($(this),"",conf,conf.errorMessagePosition);$(this).removeClass("valid").removeClass(conf.errorElementClass).css("border-color","").parent().removeClass("has-error").removeClass("has-success").find("."+conf.errorMessageClass).remove()})},_setInlineErrorMessage=function($input,mess,conf,$messageContainer){var custom=_getInlineErrorElement($input);if(custom){custom.innerHTML=mess}else if(typeof $messageContainer=="object"){var $found=false;$messageContainer.find("."+conf.errorMessageClass).each(function(){if(this.inputReferer==$input[0]){$found=$(this);return false}});if($found){if(!mess){$found.remove()}else{$found.html(mess)}}else{var $mess=$(''+mess+"
");$mess[0].inputReferer=$input[0];$messageContainer.prepend($mess)}}else{var $mess=$input.parent().find("."+conf.errorMessageClass+".help-block");if($mess.length==0){$mess=$(" ").addClass("help-block").addClass(conf.errorMessageClass);$mess.appendTo($input.parent())}$mess.html(mess)}},_getInlineErrorElement=function($input,conf){return document.getElementById($input.attr("name")+"_err_msg")};$.fn.validateOnBlur=function(language,settings){this.find("input[data-validation],textarea[data-validation],select[data-validation]").bind("blur.validation",function(){$(this).validateInputOnBlur(language,settings)});return this};$.fn.validateOnEvent=function(language,settings){this.find("input[data-validation][data-validation-event],textarea[data-validation][data-validation-event],select[data-validation][data-validation-event]").each(function(){var $el=$(this),etype=$el.attr("data-validation-event");if(etype){$el.bind(etype+".validation",function(){$(this).validateInputOnBlur(language,settings,false,etype)})}});return this};$.fn.showHelpOnFocus=function(attrName){if(!attrName){attrName="data-validation-help"}this.find(".has-help-txt").valAttr("has-keyup-event",false).valAttr("backend-valid",false).valAttr("backend-invalid",false).removeClass("has-help-txt");this.find("textarea,input").each(function(){var $elem=$(this),className="jquery_form_help_"+($elem.attr("name")||"").replace(/(:|\.|\[|\])/g,""),help=$elem.attr(attrName);if(help){$elem.addClass("has-help-txt").unbind("focus.help").bind("focus.help",function(){var $help=$elem.parent().find("."+className);if($help.length==0){$help=$(" ").addClass(className).addClass("help").addClass("help-block").text(help).hide();$elem.after($help)}$help.fadeIn()}).unbind("blur.help").bind("blur.help",function(){$(this).parent().find("."+className).fadeOut("slow")})}});return this};$.fn.validateInputOnBlur=function(language,conf,attachKeyupEvent,eventContext){if(attachKeyupEvent===undefined)attachKeyupEvent=true;if(!eventContext)eventContext="blur";if((this.valAttr("suggestion-nr")||this.valAttr("postpone")||this.hasClass("hasDatepicker"))&&!window.postponedValidation){var _self=this,postponeTime=this.valAttr("postpone")||200;window.postponedValidation=function(){_self.validateInputOnBlur(language,conf,attachKeyupEvent);window.postponedValidation=false};setTimeout(function(){if(window.postponedValidation){window.postponedValidation()}},postponeTime);return this}language=$.extend({},$.formUtils.LANG,language||{});_removeErrorStyle(this,conf);var $elem=this,$form=$elem.closest("form"),validationRule=$elem.attr(conf.validationRuleAttribute),validation=$.formUtils.validateInput($elem,language,$.extend({},conf,{errorMessagePosition:"element"}),$form,eventContext);$elem.trigger("validation",[validation===null?null:validation===true]);if(validation===true){$elem.addClass("valid").parent().addClass("has-success")}else if(validation!==null){_applyErrorStyle($elem,conf);_setInlineErrorMessage($elem,validation,conf,conf.errorMessagePosition);if(attachKeyupEvent){$elem.bind("keyup",function(){$(this).validateInputOnBlur(language,conf,false,"keyup")})}}return this};$.fn.valAttr=function(name,val){if(val===undefined){return this.attr("data-validation-"+name)}else if(val===false||val===null){return this.removeAttr("data-validation-"+name)}else{if(name.length>0)name="-"+name;return this.attr("data-validation"+name,val)}};$.fn.validateForm=function(language,conf){language=$.extend({},$.formUtils.LANG,language||{});$.formUtils.isValidatingEntireForm=true;$.formUtils.haltValidation=false;var addErrorMessage=function(mess,$elem){if(mess!==null){if($.inArray(mess,errorMessages)<0){errorMessages.push(mess)}errorInputs.push($elem);$elem.attr("current-error",mess);_applyErrorStyle($elem,conf)}},errorMessages=[],errorInputs=[],$form=this,ignoreInput=function(name,type){if(type==="submit"||type==="button"||type=="reset"){return true}return $.inArray(name,conf.ignore||[])>-1};$form.find("."+conf.errorMessageClass+".alert").remove();_removeErrorStyle($form.find("."+conf.errorElementClass+",.valid"),conf);$form.find("input,textarea,select").filter(':not([type="submit"],[type="button"])').each(function(){var $elem=$(this);var elementType=$elem.attr("type");if(!ignoreInput($elem.attr("name"),elementType)){var validation=$.formUtils.validateInput($elem,language,conf,$form,"submit");$elem.trigger("validation",[validation===true]);if(validation!==true){addErrorMessage(validation,$elem)}else{$elem.valAttr("current-error",false).addClass("valid").parent().addClass("has-success")}}});if(typeof conf.onValidate=="function"){var errors=conf.onValidate($form);if($.isArray(errors)){$.each(errors,function(i,err){addErrorMessage(err.message,err.element)})}else if(errors&&errors.element&&errors.message){addErrorMessage(errors.message,errors.element)}}if(!$.formUtils.haltValidation&&errorInputs.length>0){$.formUtils.isValidatingEntireForm=false;if(conf.errorMessagePosition==="top"){var messages=""+language.errorTitle+" ";$.each(errorMessages,function(i,mess){messages+=" * "+mess});$form.children().eq(0).before(''+messages+"
")}else{$.each(errorInputs,function(i,$input){_setInlineErrorMessage($input,$input.attr("current-error"),conf,conf.errorMessagePosition)})}if(conf.scrollToTopOnError){$(window).scrollTop($form.offset().top-20)}return false}$.formUtils.isValidatingEntireForm=false;return!$.formUtils.haltValidation};$.fn.restrictLength=function(maxLengthElement){new $.formUtils.lengthRestriction(this,maxLengthElement);return this};$.fn.addSuggestions=function(settings){var sugs=false;this.find("input").each(function(){var $field=$(this);sugs=$.split($field.attr("data-suggestions"));if(sugs.length>0&&!$field.hasClass("has-suggestions")){$.formUtils.suggest($field,sugs,settings);$field.addClass("has-suggestions")}});return this};$.split=function(val,func,delim){if(typeof func!="function"){if(!val)return[];var values=[];$.each(val.split(func?func:","),function(i,str){str=$.trim(str);if(str.length)values.push(str)});return values}else if(val){if(!delim)delim=",";$.each(val.split(delim),function(i,str){str=$.trim(str);if(str.length)return func(str,i)})}};$.validate=function(conf){var defaultConf=$.extend($.formUtils.defaultConfig(),{form:"form",validateOnEvent:true,validateOnBlur:true,showHelpOnFocus:true,addSuggestions:true,modules:"",onModulesLoaded:null,language:false,onSuccess:false,onError:false});conf=$.extend(defaultConf,conf||{});$.split(conf.form,function(formQuery){var $form=$(formQuery);$form.find(".has-help-txt").unbind("focus.validation").unbind("blur.validation");$form.removeClass("has-validation-callback").unbind("submit.validation").unbind("reset.validation").find("input[data-validation],textarea[data-validation]").unbind("blur.validation");$form.bind("submit.validation",function(){var $form=$(this);if($.formUtils.isLoadingModules){setTimeout(function(){$form.trigger("submit.validation")},200);return false}var valid=$form.validateForm(conf.language,conf);if(valid&&typeof conf.onSuccess=="function"){var callbackResponse=conf.onSuccess($form);if(callbackResponse===false)return false}else if(!valid&&typeof conf.onError=="function"){conf.onError($form);return false}else{return valid}}).bind("reset.validation",function(){$(this).find("."+conf.errorMessageClass+".alert").remove();_removeErrorStyle($(this).find("."+conf.errorElementClass+",.valid"),conf)}).addClass("has-validation-callback");if(conf.showHelpOnFocus){$form.showHelpOnFocus()}if(conf.addSuggestions){$form.addSuggestions()}if(conf.validateOnBlur){$form.validateOnBlur(conf.language,conf)}if(conf.validateOnEvent){$form.validateOnEvent(conf.language,conf)}});if(conf.modules!=""){if(typeof conf.onModulesLoaded=="function"){$.formUtils.on("load",function(){conf.onModulesLoaded()})}$.formUtils.loadModules(conf.modules)}};$.formUtils={defaultConfig:function(){return{ignore:[],errorElementClass:"error",borderColorOnError:"red",errorMessageClass:"form-error",validationRuleAttribute:"data-validation",validationErrorMsgAttribute:"data-validation-error-msg",errorMessagePosition:"element",scrollToTopOnError:true,dateFormat:"yyyy-mm-dd",addValidClassOnAll:false,decimalSeparator:"."}},validators:{},_events:{load:[],valid:[],invalid:[]},haltValidation:false,isValidatingEntireForm:false,addValidator:function(validator){var name=validator.name.indexOf("validate_")===0?validator.name:"validate_"+validator.name;if(validator.validateOnKeyUp===undefined)validator.validateOnKeyUp=true;this.validators[name]=validator},on:function(evt,callback){if(this._events[evt]===undefined)this._events[evt]=[];this._events[evt].push(callback)},trigger:function(evt,argA,argB){$.each(this._events[evt]||[],function(i,func){func(argA,argB)})},isLoadingModules:false,loadedModules:{},loadModules:function(modules,path,fireEvent){if(fireEvent===undefined)fireEvent=true;if($.formUtils.isLoadingModules){setTimeout(function(){$.formUtils.loadModules(modules,path,fireEvent)});return}var hasLoadedAnyModule=false,loadModuleScripts=function(modules,path){var moduleList=$.split(modules),numModules=moduleList.length,moduleLoadedCallback=function(){numModules--;if(numModules==0){$.formUtils.isLoadingModules=false;if(fireEvent&&hasLoadedAnyModule){$.formUtils.trigger("load",path)}}};if(numModules>0){$.formUtils.isLoadingModules=true}var cacheSuffix="?__="+(new Date).getTime(),appendToElement=document.getElementsByTagName("head")[0]||document.getElementsByTagName("body")[0];$.each(moduleList,function(i,modName){modName=$.trim(modName);if(modName.length==0){moduleLoadedCallback()}else{var scriptUrl=path+modName+(modName.substr(-3)==".js"?"":".js"),script=document.createElement("SCRIPT");if(scriptUrl in $.formUtils.loadedModules){moduleLoadedCallback()}else{$.formUtils.loadedModules[scriptUrl]=1;hasLoadedAnyModule=true;script.type="text/javascript";script.onload=moduleLoadedCallback;script.src=scriptUrl+(scriptUrl.substr(-7)==".dev.js"?cacheSuffix:"");script.onreadystatechange=function(){if(this.readyState=="complete"){moduleLoadedCallback()}};appendToElement.appendChild(script)}}})};if(path){loadModuleScripts(modules,path)}else{var findScriptPathAndLoadModules=function(){var foundPath=false;$("script").each(function(){if(this.src){var scriptName=this.src.substr(this.src.lastIndexOf("/")+1,this.src.length);if(scriptName.indexOf("jquery.form-validator.js")>-1||scriptName.indexOf("jquery.form-validator.min.js")>-1){foundPath=this.src.substr(0,this.src.lastIndexOf("/"))+"/";if(foundPath=="/")foundPath="";return false}}});if(foundPath!==false){loadModuleScripts(modules,foundPath);return true}return false};if(!findScriptPathAndLoadModules()){$(findScriptPathAndLoadModules)}}},validateInput:function($elem,language,conf,$form,eventContext){if($elem.attr("disabled"))return null;$elem.trigger("beforeValidation");var value=$.trim($elem.val()||""),optional=$elem.valAttr("optional"),validationDependsOnCheckedInput=false,validationDependentInputIsChecked=false,validateIfCheckedElement=false,validateIfCheckedElementName=$elem.valAttr("if-checked");if(validateIfCheckedElementName!=null){validationDependsOnCheckedInput=true;validateIfCheckedElement=$form.find('input[name="'+validateIfCheckedElementName+'"]');if(validateIfCheckedElement.prop("checked")){validationDependentInputIsChecked=true}}if(!value&&optional==="true"||validationDependsOnCheckedInput&&!validationDependentInputIsChecked){return conf.addValidClassOnAll?true:null}var validationRules=$elem.attr(conf.validationRuleAttribute),validationErrorMsg=true;if(!validationRules){return conf.addValidClassOnAll?true:null}$.split(validationRules,function(rule){if(rule.indexOf("validate_")!==0){rule="validate_"+rule}var validator=$.formUtils.validators[rule];if(validator&&typeof validator["validatorFunction"]=="function"){if(rule=="validate_checkbox_group"){$elem=$("[name='"+$elem.attr("name")+"']:eq(0)")}var isValid=true;if(eventContext!="keyup"||validator.validateOnKeyUp){isValid=validator.validatorFunction(value,$elem,conf,language,$form)}if(!isValid){validationErrorMsg=$elem.attr(conf.validationErrorMsgAttribute);if(!validationErrorMsg){validationErrorMsg=language[validator.errorMessageKey];if(!validationErrorMsg)validationErrorMsg=validator.errorMessage}return false}}else{console.warn('Using undefined validator "'+rule+'"')}}," ");if(typeof validationErrorMsg=="string"){return validationErrorMsg}else{return true}},parseDate:function(val,dateFormat){var divider=dateFormat.replace(/[a-zA-Z]/gi,"").substring(0,1),regexp="^",formatParts=dateFormat.split(divider),matches,day,month,year;$.each(formatParts,function(i,part){regexp+=(i>0?"\\"+divider:"")+"(\\d{"+part.length+"})"});regexp+="$";matches=val.match(new RegExp(regexp));if(matches===null){return false}var findDateUnit=function(unit,formatParts,matches){for(var i=0;i28&&(year%4!==0||year%100===0&&year%400!==0)||month===2&&day>29&&(year%4===0||year%100!==0&&year%400===0)||month>12||month===0){return false}if(this.isShortMonth(month)&&day>30||!this.isShortMonth(month)&&day>31||day===0){return false}return[year,month,day]},parseDateInt:function(val){if(val.indexOf("0")===0){val=val.replace("0","")}return parseInt(val,10)},isShortMonth:function(m){return m%2===0&&m<7||m%2!==0&&m>7},lengthRestriction:function($inputElement,$maxLengthElement){var maxChars=parseInt($maxLengthElement.text(),10),charsLeft=0,countCharacters=function(){var numChars=$inputElement.val().length;if(numChars>maxChars){var currScrollTopPos=$inputElement.scrollTop();$inputElement.val($inputElement.val().substring(0,maxChars));$inputElement.scrollTop(currScrollTopPos)}charsLeft=maxChars-numChars;if(charsLeft<0)charsLeft=0;$maxLengthElement.text(charsLeft)};$($inputElement).bind("keydown keyup keypress focus blur",countCharacters).bind("cut paste",function(){setTimeout(countCharacters,100)});$(document).bind("ready",countCharacters)},numericRangeCheck:function(value,rangeAllowed){var range=$.split(rangeAllowed,"-");var minmax=parseInt(rangeAllowed.substr(3),10);if(range.length==2&&(valueparseInt(range[1],10))){return["out",range[0],range[1]]}else if(rangeAllowed.indexOf("min")===0&&valueminmax){return["max",minmax]}else{return["ok"]}},_numSuggestionElements:0,_selectedSuggestion:null,_previousTypedVal:null,suggest:function($elem,suggestions,settings){var conf={css:{maxHeight:"150px",background:"#FFF",lineHeight:"150%",textDecoration:"underline",overflowX:"hidden",overflowY:"auto",border:"#CCC solid 1px",borderTop:"none",cursor:"pointer"},activeSuggestionCSS:{background:"#E9E9E9"}},setSuggsetionPosition=function($suggestionContainer,$input){var offset=$input.offset();$suggestionContainer.css({width:$input.outerWidth(),left:offset.left+"px",top:offset.top+$input.outerHeight()+"px"})};if(settings)$.extend(conf,settings);conf.css["position"]="absolute";conf.css["z-index"]=9999;$elem.attr("autocomplete","off");if(this._numSuggestionElements===0){$(window).bind("resize",function(){$(".jquery-form-suggestions").each(function(){var $container=$(this),suggestID=$container.attr("data-suggest-container");setSuggsetionPosition($container,$(".suggestions-"+suggestID).eq(0))})})}this._numSuggestionElements++;var onSelectSuggestion=function($el){var suggestionId=$el.valAttr("suggestion-nr");$.formUtils._selectedSuggestion=null;$.formUtils._previousTypedVal=null;$(".jquery-form-suggestion-"+suggestionId).fadeOut("fast")};$elem.data("suggestions",suggestions).valAttr("suggestion-nr",this._numSuggestionElements).unbind("focus.suggest").bind("focus.suggest",function(){$(this).trigger("keyup");$.formUtils._selectedSuggestion=null}).unbind("keyup.suggest").bind("keyup.suggest",function(){var $input=$(this),foundSuggestions=[],val=$.trim($input.val()).toLocaleLowerCase();if(val==$.formUtils._previousTypedVal){return}else{$.formUtils._previousTypedVal=val}var hasTypedSuggestion=false,suggestionId=$input.valAttr("suggestion-nr"),$suggestionContainer=$(".jquery-form-suggestion-"+suggestionId);$suggestionContainer.scrollTop(0);if(val!=""){var findPartial=val.length>2;$.each($input.data("suggestions"),function(i,suggestion){var lowerCaseVal=suggestion.toLocaleLowerCase();if(lowerCaseVal==val){foundSuggestions.push(""+suggestion+" ");hasTypedSuggestion=true;return false}else if(lowerCaseVal.indexOf(val)===0||findPartial&&lowerCaseVal.indexOf(val)>-1){foundSuggestions.push(suggestion.replace(new RegExp(val,"gi"),"$& "))}})}if(hasTypedSuggestion||foundSuggestions.length==0&&$suggestionContainer.length>0){$suggestionContainer.hide()}else if(foundSuggestions.length>0&&$suggestionContainer.length==0){$suggestionContainer=$("
").css(conf.css).appendTo("body");$elem.addClass("suggestions-"+suggestionId);$suggestionContainer.attr("data-suggest-container",suggestionId).addClass("jquery-form-suggestions").addClass("jquery-form-suggestion-"+suggestionId)}else if(foundSuggestions.length>0&&!$suggestionContainer.is(":visible")){$suggestionContainer.show()}if(foundSuggestions.length>0&&val.length!=foundSuggestions[0].length){setSuggsetionPosition($suggestionContainer,$input);$suggestionContainer.html("");$.each(foundSuggestions,function(i,text){$("
").append(text).css({overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",padding:"5px"}).addClass("form-suggest-element").appendTo($suggestionContainer).click(function(){$input.focus();$input.val($(this).text());onSelectSuggestion($input)})})}}).unbind("keydown.validation").bind("keydown.validation",function(e){var code=e.keyCode?e.keyCode:e.which,suggestionId,$suggestionContainer,$input=$(this);if(code==13&&$.formUtils._selectedSuggestion!==null){suggestionId=$input.valAttr("suggestion-nr");$suggestionContainer=$(".jquery-form-suggestion-"+suggestionId);if($suggestionContainer.length>0){var newText=$suggestionContainer.find("div").eq($.formUtils._selectedSuggestion).text();$input.val(newText);onSelectSuggestion($input);e.preventDefault()}}else{suggestionId=$input.valAttr("suggestion-nr");$suggestionContainer=$(".jquery-form-suggestion-"+suggestionId);var $suggestions=$suggestionContainer.children();if($suggestions.length>0&&$.inArray(code,[38,40])>-1){if(code==38){if($.formUtils._selectedSuggestion===null)$.formUtils._selectedSuggestion=$suggestions.length-1;else $.formUtils._selectedSuggestion--;if($.formUtils._selectedSuggestion<0)$.formUtils._selectedSuggestion=$suggestions.length-1}else if(code==40){if($.formUtils._selectedSuggestion===null)$.formUtils._selectedSuggestion=0;else $.formUtils._selectedSuggestion++;if($.formUtils._selectedSuggestion>$suggestions.length-1)$.formUtils._selectedSuggestion=0}var containerInnerHeight=$suggestionContainer.innerHeight(),containerScrollTop=$suggestionContainer.scrollTop(),suggestionHeight=$suggestionContainer.children().eq(0).outerHeight(),activeSuggestionPosY=suggestionHeight*$.formUtils._selectedSuggestion;if(activeSuggestionPosYcontainerScrollTop+containerInnerHeight){$suggestionContainer.scrollTop(activeSuggestionPosY)}$suggestions.removeClass("active-suggestion").css("background","none").eq($.formUtils._selectedSuggestion).addClass("active-suggestion").css(conf.activeSuggestionCSS);e.preventDefault();return false}}}).unbind("blur.suggest").bind("blur.suggest",function(){onSelectSuggestion($(this))});return $elem},LANG:{errorTitle:"Form submission failed!",requiredFields:"You have not answered all required fields",badTime:"You have not given a correct time",badEmail:"You have not given a correct e-mail address",badTelephone:"You have not given a correct phone number",badSecurityAnswer:"You have not given a correct answer to the security question",badDate:"You have not given a correct date",lengthBadStart:"You must give an answer between ",lengthBadEnd:" characters",lengthTooLongStart:"You have given an answer longer than ",lengthTooShortStart:"You have given an answer shorter than ",notConfirmed:"Values could not be confirmed",badDomain:"Incorrect domain value",badUrl:"The answer you gave was not a correct URL",badCustomVal:"You gave an incorrect answer",badInt:"The answer you gave was not a correct number",badSecurityNumber:"Your social security number was incorrect",badUKVatAnswer:"Incorrect UK VAT Number",badStrength:"The password isn't strong enough",badNumberOfSelectedOptionsStart:"You have to choose at least ",badNumberOfSelectedOptionsEnd:" answers",badAlphaNumeric:"The answer you gave must contain only alphanumeric characters ",badAlphaNumericExtra:" and ",wrongFileSize:"The file you are trying to upload is too large",wrongFileType:"The file you are trying to upload is of wrong type",groupCheckedRangeStart:"Please choose between ",groupCheckedTooFewStart:"Please choose at least ",groupCheckedTooManyStart:"Please choose a maximum of ",groupCheckedEnd:" item(s)"}};$.formUtils.addValidator({name:"email",validatorFunction:function(email){var emailParts=email.toLowerCase().split("@");if(emailParts.length==2){return $.formUtils.validators.validate_domain.validatorFunction(emailParts[1])&&!/[^\w\+\.\-]/.test(emailParts[0])}return false},errorMessage:"",errorMessageKey:"badEmail"});$.formUtils.addValidator({name:"domain",validatorFunction:function(val,$input){var topDomains=[".ac",".ad",".ae",".aero",".af",".ag",".ai",".al",".am",".an",".ao",".aq",".ar",".arpa",".as",".asia",".at",".au",".aw",".ax",".az",".ba",".bb",".bd",".be",".bf",".bg",".bh",".bi",".bike",".biz",".bj",".bm",".bn",".bo",".br",".bs",".bt",".bv",".bw",".by",".bz",".ca",".camera",".cat",".cc",".cd",".cf",".cg",".ch",".ci",".ck",".cl",".clothing",".cm",".cn",".co",".com",".construction",".contractors",".coop",".cr",".cu",".cv",".cw",".cx",".cy",".cz",".de",".diamonds",".directory",".dj",".dk",".dm",".do",".dz",".ec",".edu",".ee",".eg",".enterprises",".equipment",".er",".es",".estate",".et",".eu",".fi",".fj",".fk",".fm",".fo",".fr",".ga",".gallery",".gb",".gd",".ge",".gf",".gg",".gh",".gi",".gl",".gm",".gn",".gov",".gp",".gq",".gr",".graphics",".gs",".gt",".gu",".guru",".gw",".gy",".hk",".hm",".hn",".holdings",".hr",".ht",".hu",".id",".ie",".il",".im",".in",".info",".int",".io",".iq",".ir",".is",".it",".je",".jm",".jo",".jobs",".jp",".ke",".kg",".kh",".ki",".kitchen",".km",".kn",".kp",".kr",".kw",".ky",".kz",".la",".land",".lb",".lc",".li",".lighting",".lk",".lr",".ls",".lt",".lu",".lv",".ly",".ma",".mc",".md",".me",".menu",".mg",".mh",".mil",".mk",".ml",".mm",".mn",".mo",".mobi",".mp",".mq",".mr",".ms",".mt",".mu",".museum",".mv",".mw",".mx",".my",".mz",".na",".name",".nc",".ne",".net",".nf",".ng",".ni",".nl",".no",".np",".nr",".nu",".nz",".om",".org",".pa",".pe",".pf",".pg",".ph",".photography",".pk",".pl",".plumbing",".pm",".pn",".post",".pr",".pro",".ps",".pt",".pw",".py",".qa",".re",".ro",".rs",".ru",".rw",".sa",".sb",".sc",".sd",".se",".sexy",".sg",".sh",".si",".singles",".sj",".sk",".sl",".sm",".sn",".so",".sr",".st",".su",".sv",".sx",".sy",".sz",".tattoo",".tc",".td",".technology",".tel",".tf",".tg",".th",".tips",".tj",".tk",".tl",".tm",".tn",".to",".today",".tp",".tr",".travel",".tt",".tv",".tw",".tz",".ua",".ug",".uk",".uno",".us",".uy",".uz",".va",".vc",".ve",".ventures",".vg",".vi",".vn",".voyage",".vu",".wf",".ws",".xn--3e0b707e",".xn--45brj9c",".xn--80ao21a",".xn--80asehdb",".xn--80aswg",".xn--90a3ac",".xn--clchc0ea0b2g2a9gcd",".xn--fiqs8s",".xn--fiqz9s",".xn--fpcrj9c3d",".xn--fzc2c9e2c",".xn--gecrj9c",".xn--h2brj9c",".xn--j1amh",".xn--j6w193g",".xn--kprw13d",".xn--kpry57d",".xn--l1acc",".xn--lgbbat1ad8j",".xn--mgb9awbf",".xn--mgba3a4f16a",".xn--mgbaam7a8h",".xn--mgbayh7gpa",".xn--mgbbh1a71e",".xn--mgbc0a9azcg",".xn--mgberp4a5d4ar",".xn--mgbx4cd0ab",".xn--ngbc5azd",".xn--o3cw4h",".xn--ogbpf8fl",".xn--p1ai",".xn--pgbs0dh",".xn--q9jyb4c",".xn--s9brj9c",".xn--unup4y",".xn--wgbh1c",".xn--wgbl6a",".xn--xkc2al3hye2a",".xn--xkc2dl3a5ee0h",".xn--yfro4i67o",".xn--ygbi2ammx",".xxx",".ye",".yt",".za",".zm",".zw"],ukTopDomains=["co","me","ac","gov","judiciary","ltd","mod","net","nhs","nic","org","parliament","plc","police","sch","bl","british-library","jet","nls"],dot=val.lastIndexOf("."),domain=val.substring(0,dot),ext=val.substring(dot,val.length),hasTopDomain=false;for(var i=0;i<2||dot>57){return false}else{var firstChar=domain.substring(0,1),lastChar=domain.substring(domain.length-1,domain.length);if(firstChar==="-"||firstChar==="."||lastChar==="-"||lastChar==="."){return false}if(domain.split(".").length>3||domain.split("..").length>1){return false}if(domain.replace(/[-\da-z\.]/g,"")!==""){return false}}if(typeof $input!=="undefined"){$input.val(val)}return true},errorMessage:"",errorMessageKey:"badDomain"});$.formUtils.addValidator({name:"required",validatorFunction:function(val,$el){return $el.attr("type")=="checkbox"?$el.is(":checked"):$.trim(val)!==""},errorMessage:"",errorMessageKey:"requiredFields"});$.formUtils.addValidator({name:"length",validatorFunction:function(val,$el,conf,lang){var lengthAllowed=$el.valAttr("length"),type=$el.attr("type");if(lengthAllowed==undefined){var elementType=$el.get(0).nodeName;alert('Please add attribute "data-validation-length" to '+elementType+" named "+$el.attr("name"));return true}var len=type=="file"&&$el.get(0).files!==undefined?$el.get(0).files.length:val.length,lengthCheckResults=$.formUtils.numericRangeCheck(len,lengthAllowed),checkResult;switch(lengthCheckResults[0]){case"out":this.errorMessage=lang.lengthBadStart+lengthAllowed+lang.lengthBadEnd;checkResult=false;break;case"min":this.errorMessage=lang.lengthTooShortStart+lengthCheckResults[1]+lang.lengthBadEnd;checkResult=false;break;case"max":this.errorMessage=lang.lengthTooLongStart+lengthCheckResults[1]+lang.lengthBadEnd;checkResult=false;break;default:checkResult=true}return checkResult},errorMessage:"",errorMessageKey:""});$.formUtils.addValidator({name:"url",validatorFunction:function(url){var urlFilter=/^(https?|ftp):\/\/((((\w|-|\.|~|[\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])(\w|-|\.|~|[\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])(\w|-|\.|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/(((\w|-|\.|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/((\w|-|\.|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|\[|\]|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#(((\w|-|\.|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i;if(urlFilter.test(url)){var domain=url.split("://")[1];var domainSlashPos=domain.indexOf("/");if(domainSlashPos>-1)domain=domain.substr(0,domainSlashPos);return $.formUtils.validators.validate_domain.validatorFunction(domain)}return false},errorMessage:"",errorMessageKey:"badUrl"});$.formUtils.addValidator({name:"number",validatorFunction:function(val,$el,conf){if(val!==""){var allowing=$el.valAttr("allowing")||"",decimalSeparator=$el.valAttr("decimal-separator")||conf.decimalSeparator,allowsRange=false,begin,end;if(allowing.indexOf("number")==-1)allowing+=",number";if(allowing.indexOf("negative")>-1&&val.indexOf("-")===0){val=val.substr(1)}if(allowing.indexOf("range")>-1){begin=parseFloat(allowing.substring(allowing.indexOf("[")+1,allowing.indexOf(";")));end=parseFloat(allowing.substring(allowing.indexOf(";")+1,allowing.indexOf("]")));allowsRange=true}if(decimalSeparator==","){val=val.replace(",",".")}if(allowing.indexOf("number")>-1&&val.replace(/[0-9]/g,"")===""&&(!allowsRange||val>=begin&&val<=end)){return true}if(allowing.indexOf("float")>-1&&val.match(new RegExp("^([0-9]+)\\.([0-9]+)$"))!==null&&(!allowsRange||val>=begin&&val<=end)){return true}}return false},errorMessage:"",errorMessageKey:"badInt"});$.formUtils.addValidator({name:"alphanumeric",validatorFunction:function(val,$el,conf,language){var patternStart="^([a-zA-Z0-9",patternEnd="]+)$",additionalChars=$el.attr("data-validation-allowing"),pattern="";if(additionalChars){pattern=patternStart+additionalChars+patternEnd;var extra=additionalChars.replace(/\\/g,"");if(extra.indexOf(" ")>-1){extra=extra.replace(" ","");extra+=" and spaces "}this.errorMessage=language.badAlphaNumeric+language.badAlphaNumericExtra+extra}else{pattern=patternStart+patternEnd;this.errorMessage=language.badAlphaNumeric}return new RegExp(pattern).test(val)},errorMessage:"",errorMessageKey:""});$.formUtils.addValidator({name:"custom",validatorFunction:function(val,$el,conf){var regexp=new RegExp($el.valAttr("regexp"));return regexp.test(val)},errorMessage:"",errorMessageKey:"badCustomVal"});$.formUtils.addValidator({name:"date",validatorFunction:function(date,$el,conf){var dateFormat="yyyy-mm-dd";if($el.valAttr("format")){dateFormat=$el.valAttr("format")}else if(conf.dateFormat){dateFormat=conf.dateFormat}return $.formUtils.parseDate(date,dateFormat)!==false},errorMessage:"",errorMessageKey:"badDate"});$.formUtils.addValidator({name:"checkbox_group",validatorFunction:function(val,$el,conf,lang,$form){var checkResult=true;var elname=$el.attr("name");var checkedCount=$("input[type=checkbox][name^='"+elname+"']:checked",$form).length;var qtyAllowed=$el.valAttr("qty");if(qtyAllowed==undefined){var elementType=$el.get(0).nodeName;alert('Attribute "data-validation-qty" is missing from '+elementType+" named "+$el.attr("name"))}var qtyCheckResults=$.formUtils.numericRangeCheck(checkedCount,qtyAllowed);switch(qtyCheckResults[0]){case"out":this.errorMessage=lang.groupCheckedRangeStart+qtyAllowed+lang.groupCheckedEnd;checkResult=false;break;case"min":this.errorMessage=lang.groupCheckedTooFewStart+qtyCheckResults[1]+lang.groupCheckedEnd;checkResult=false;break;case"max":this.errorMessage=lang.groupCheckedTooManyStart+qtyCheckResults[1]+lang.groupCheckedEnd;
-checkResult=false;break;default:checkResult=true}return checkResult}})})(jQuery);
\ No newline at end of file
diff --git a/form-validator/location.dev.js b/form-validator/location.dev.js
deleted file mode 100644
index 84037d6..0000000
--- a/form-validator/location.dev.js
+++ /dev/null
@@ -1,78 +0,0 @@
-/**
- * jQuery Form Validator Module: Date
- * ------------------------------------------
- * Created by Victor Jonsson
- *
- * The following validators will be added by this module:
- * - Country
- * - US state
- * - longitude and latitude
- *
- * @website http://formvalidator.net/#location-validators
- * @license Dual licensed under the MIT or GPL Version 2 licenses
- * @version 2.1.47
- */
-(function($) {
-
- /*
- * Validate that country exists
- */
- $.formUtils.addValidator({
- name : 'country',
- validatorFunction : function(str) {
- return $.inArray(str.toLowerCase(), this.countries) > -1;
- },
- countries : ['afghanistan','albania','algeria','american samoa','andorra','angola','anguilla','antarctica','antigua and barbuda','arctic ocean','argentina','armenia','aruba','ashmore and cartier islands','atlantic ocean','australia','austria','azerbaijan','bahamas','bahrain','baltic sea','baker island','bangladesh','barbados','bassas da india','belarus','belgium','belize','benin','bermuda','bhutan','bolivia','borneo','bosnia and herzegovina','botswana','bouvet island','brazil','british virgin islands','brunei','bulgaria','burkina faso','burundi','cambodia','cameroon','canada','cape verde','cayman islands','central african republic','chad','chile','china','christmas island','clipperton island','cocos islands','colombia','comoros','cook islands','coral sea islands','costa rica','croatia','cuba','cyprus','czech republic','democratic republic of the congo','denmark','djibouti','dominica','dominican republic','east timor','ecuador','egypt','el salvador','equatorial guinea','eritrea','estonia','ethiopia','europa island','falkland islands','faroe islands','fiji','finland','france','french guiana','french polynesia','french southern and antarctic lands','gabon','gambia','gaza strip','georgia','germany','ghana','gibraltar','glorioso islands','greece','greenland','grenada','guadeloupe','guam','guatemala','guernsey','guinea','guinea-bissau','guyana','haiti','heard island and mcdonald islands','honduras','hong kong','howland island','hungary','iceland','india','indian ocean','indonesia','iran','iraq','ireland','isle of man','israel','italy','jamaica','jan mayen','japan','jarvis island','jersey','johnston atoll','jordan','juan de nova island','kazakhstan','kenya','kerguelen archipelago','kingman reef','kiribati','kosovo','kuwait','kyrgyzstan','laos','latvia','lebanon','lesotho','liberia','libya','liechtenstein','lithuania','luxembourg','macau','macedonia','madagascar','malawi','malaysia','maldives','mali','malta','marshall islands','martinique','mauritania','mauritius','mayotte','mediterranean sea','mexico','micronesia','midway islands','moldova','monaco','mongolia','montenegro','montserrat','morocco','mozambique','myanmar','namibia','nauru','navassa island','nepal','netherlands','netherlands antilles','new caledonia','new zealand','nicaragua','niger','nigeria','niue','norfolk island','north korea','north sea','northern mariana islands','norway','oman','pacific ocean','pakistan','palau','palmyra atoll','panama','papua new guinea','paracel islands','paraguay','peru','philippines','pitcairn islands','poland','portugal','puerto rico','qatar','republic of the congo','reunion','romania','ross sea','russia','rwanda','saint helena','saint kitts and nevis','saint lucia','saint pierre and miquelon','saint vincent and the grenadines','samoa','san marino','sao tome and principe','saudi arabia','senegal','serbia','seychelles','sierra leone','singapore','slovakia','slovenia','solomon islands','somalia','south africa','south georgia and the south sandwich islands','south korea','southern ocean','spain','spratly islands','sri lanka','sudan','suriname','svalbard','swaziland','sweden','switzerland','syria','taiwan','tajikistan','tanzania','tasman sea','thailand','togo','tokelau','tonga','trinidad and tobago','tromelin island','tunisia','turkey','turkmenistan','turks and caicos islands','tuvalu','uganda','ukraine','united arab emirates','united kingdom','uruguay','usa','uzbekistan','vanuatu','venezuela','viet nam','virgin islands','wake island','wallis and futuna','west bank','western sahara','yemen','zambia','zimbabwe'],
- errorMessage : '',
- errorMessageKey: 'badCustomVal'
- });
-
- /*
- * Is this a valid federate state in the US
- */
- $.formUtils.addValidator({
- name : 'federatestate',
- validatorFunction : function(str) {
- return $.inArray(str.toLowerCase(), this.states) > -1;
- },
- states : ['alabama','alaska', 'arizona', 'arkansas','california','colorado','connecticut','delaware','florida','georgia','hawaii','idaho','illinois','indiana','iowa','kansas','kentucky','louisiana','maine','maryland', 'district of columbia', 'massachusetts','michigan','minnesota','mississippi','missouri','montana','nebraska','nevada','new hampshire','new jersey','new mexico','new york','north carolina','north dakota','ohio','oklahoma','oregon','pennsylvania','rhode island','south carolina','south dakota','tennessee','texas','utah','vermont','virginia','washington','west virginia','wisconsin','wyoming'],
- errorMessage : '',
- errorMessageKey: 'badCustomVal'
- });
-
-
- $.formUtils.addValidator({
- name : 'longlat',
- validatorFunction : function(str) {
- var regexp = /^[+-]?\d+\.\d+, ?[+-]?\d+\.\d+$/;
- return regexp.test(str);
- },
- errorMessage:'',
- errorMessageKey:'badCustomVal'
- });
-
- /**
- * @private
- * @param {Array} listItems
- * @return {Array}
- */
- var _makeSortedList = function(listItems) {
- var newList = [];
- $.each(listItems, function(i, v) {
- newList.push(v.substr(0,1).toUpperCase() + v.substr(1, v.length));
- });
- newList.sort();
- return newList;
- };
-
- $.fn.suggestCountry = function(settings) {
- var country = _makeSortedList($.formUtils.validators.validate_country.countries);
- return $.formUtils.suggest(this, country, settings);
- };
-
- $.fn.suggestState = function(settings) {
- var states = _makeSortedList($.formUtils.validators.validate_federatestate.states);
- return $.formUtils.suggest(this, states, settings);
- };
-
-})(jQuery);
\ No newline at end of file
diff --git a/form-validator/location.js b/form-validator/location.js
deleted file mode 100644
index 15c21dc..0000000
--- a/form-validator/location.js
+++ /dev/null
@@ -1 +0,0 @@
-(function($){$.formUtils.addValidator({name:"country",validatorFunction:function(str){return $.inArray(str.toLowerCase(),this.countries)>-1},countries:["afghanistan","albania","algeria","american samoa","andorra","angola","anguilla","antarctica","antigua and barbuda","arctic ocean","argentina","armenia","aruba","ashmore and cartier islands","atlantic ocean","australia","austria","azerbaijan","bahamas","bahrain","baltic sea","baker island","bangladesh","barbados","bassas da india","belarus","belgium","belize","benin","bermuda","bhutan","bolivia","borneo","bosnia and herzegovina","botswana","bouvet island","brazil","british virgin islands","brunei","bulgaria","burkina faso","burundi","cambodia","cameroon","canada","cape verde","cayman islands","central african republic","chad","chile","china","christmas island","clipperton island","cocos islands","colombia","comoros","cook islands","coral sea islands","costa rica","croatia","cuba","cyprus","czech republic","democratic republic of the congo","denmark","djibouti","dominica","dominican republic","east timor","ecuador","egypt","el salvador","equatorial guinea","eritrea","estonia","ethiopia","europa island","falkland islands","faroe islands","fiji","finland","france","french guiana","french polynesia","french southern and antarctic lands","gabon","gambia","gaza strip","georgia","germany","ghana","gibraltar","glorioso islands","greece","greenland","grenada","guadeloupe","guam","guatemala","guernsey","guinea","guinea-bissau","guyana","haiti","heard island and mcdonald islands","honduras","hong kong","howland island","hungary","iceland","india","indian ocean","indonesia","iran","iraq","ireland","isle of man","israel","italy","jamaica","jan mayen","japan","jarvis island","jersey","johnston atoll","jordan","juan de nova island","kazakhstan","kenya","kerguelen archipelago","kingman reef","kiribati","kosovo","kuwait","kyrgyzstan","laos","latvia","lebanon","lesotho","liberia","libya","liechtenstein","lithuania","luxembourg","macau","macedonia","madagascar","malawi","malaysia","maldives","mali","malta","marshall islands","martinique","mauritania","mauritius","mayotte","mediterranean sea","mexico","micronesia","midway islands","moldova","monaco","mongolia","montenegro","montserrat","morocco","mozambique","myanmar","namibia","nauru","navassa island","nepal","netherlands","netherlands antilles","new caledonia","new zealand","nicaragua","niger","nigeria","niue","norfolk island","north korea","north sea","northern mariana islands","norway","oman","pacific ocean","pakistan","palau","palmyra atoll","panama","papua new guinea","paracel islands","paraguay","peru","philippines","pitcairn islands","poland","portugal","puerto rico","qatar","republic of the congo","reunion","romania","ross sea","russia","rwanda","saint helena","saint kitts and nevis","saint lucia","saint pierre and miquelon","saint vincent and the grenadines","samoa","san marino","sao tome and principe","saudi arabia","senegal","serbia","seychelles","sierra leone","singapore","slovakia","slovenia","solomon islands","somalia","south africa","south georgia and the south sandwich islands","south korea","southern ocean","spain","spratly islands","sri lanka","sudan","suriname","svalbard","swaziland","sweden","switzerland","syria","taiwan","tajikistan","tanzania","tasman sea","thailand","togo","tokelau","tonga","trinidad and tobago","tromelin island","tunisia","turkey","turkmenistan","turks and caicos islands","tuvalu","uganda","ukraine","united arab emirates","united kingdom","uruguay","usa","uzbekistan","vanuatu","venezuela","viet nam","virgin islands","wake island","wallis and futuna","west bank","western sahara","yemen","zambia","zimbabwe"],errorMessage:"",errorMessageKey:"badCustomVal"});$.formUtils.addValidator({name:"federatestate",validatorFunction:function(str){return $.inArray(str.toLowerCase(),this.states)>-1},states:["alabama","alaska","arizona","arkansas","california","colorado","connecticut","delaware","florida","georgia","hawaii","idaho","illinois","indiana","iowa","kansas","kentucky","louisiana","maine","maryland","district of columbia","massachusetts","michigan","minnesota","mississippi","missouri","montana","nebraska","nevada","new hampshire","new jersey","new mexico","new york","north carolina","north dakota","ohio","oklahoma","oregon","pennsylvania","rhode island","south carolina","south dakota","tennessee","texas","utah","vermont","virginia","washington","west virginia","wisconsin","wyoming"],errorMessage:"",errorMessageKey:"badCustomVal"});$.formUtils.addValidator({name:"longlat",validatorFunction:function(str){var regexp=/^[+-]?\d+\.\d+, ?[+-]?\d+\.\d+$/;return regexp.test(str)},errorMessage:"",errorMessageKey:"badCustomVal"});var _makeSortedList=function(listItems){var newList=[];$.each(listItems,function(i,v){newList.push(v.substr(0,1).toUpperCase()+v.substr(1,v.length))});newList.sort();return newList};$.fn.suggestCountry=function(settings){var country=_makeSortedList($.formUtils.validators.validate_country.countries);return $.formUtils.suggest(this,country,settings)};$.fn.suggestState=function(settings){var states=_makeSortedList($.formUtils.validators.validate_federatestate.states);return $.formUtils.suggest(this,states,settings)}})(jQuery);
\ No newline at end of file
diff --git a/form-validator/qunit.html b/form-validator/qunit.html
deleted file mode 100644
index fabbd3d..0000000
--- a/form-validator/qunit.html
+++ /dev/null
@@ -1,495 +0,0 @@
-
-
-
-
- QUnit Tests
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/form-validator/security.dev.js b/form-validator/security.dev.js
deleted file mode 100644
index 56f053e..0000000
--- a/form-validator/security.dev.js
+++ /dev/null
@@ -1,356 +0,0 @@
-/**
- * jQuery Form Validator Module: Security
- * ------------------------------------------
- * Created by Victor Jonsson
- *
- * This module adds validators typically used in registration forms.
- * This module adds the following validators:
- * - spamcheck
- * - confirmation
- * - strength
- * - backend
- *
- * @website http://formvalidator.net/#security-validators
- * @license Dual licensed under the MIT or GPL Version 2 licenses
- * @version 2.1.47
- */
-(function($) {
-
- /*
- * Simple spam check
- */
- $.formUtils.addValidator({
- name : 'spamcheck',
- validatorFunction : function(val, $el, config) {
- var attr = $el.valAttr('captcha');
- return attr === val;
- },
- errorMessage : '',
- errorMessageKey: 'badSecurityAnswer'
- });
-
-
- /*
- * Validate confirmation
- */
- $.formUtils.addValidator({
- name : 'confirmation',
- validatorFunction : function(value, $el, config, language, $form) {
- var conf = '',
- confInputName = $el.attr('name') + '_confirmation',
- confInput = $form.find('input[name="' +confInputName+ '"]').eq(0);
- if (confInput) {
- conf = confInput.val();
- } else {
- console.warn('Could not find an input with name "'+confInputName+'"');
- }
-
- return value === conf;
- },
- errorMessage : '',
- errorMessageKey: 'notConfirmed'
- });
-
- /*
- * Validate password strength
- */
- $.formUtils.addValidator({
- name : 'strength',
- validatorFunction : function(val, $el, conf) {
- var requiredStrength = $el.valAttr('strength')
- if(requiredStrength && requiredStrength > 3)
- requiredStrength = 3;
-
- return $.formUtils.validators.validate_strength.calculatePasswordStrength(val) >= requiredStrength;
- },
- errorMessage : '',
- errorMessageKey: 'badStrength',
-
- /**
- * Code more or less borrowed from jQuery plugin "Password Strength Meter"
- * written by Darren Mason (djmason9@gmail.com), myPocket technologies (www.mypocket-technologies.com)
- * @param {String} password
- * @return {Number}
- */
- calculatePasswordStrength : function(password) {
-
- if (password.length < 4) {
- return 0;
- }
-
- var score = 0;
-
- var checkRepetition = function (pLen, str) {
- var res = "";
- for (var i = 0; i < str.length; i++) {
- var repeated = true;
-
- for (var j = 0; j < pLen && (j + i + pLen) < str.length; j++) {
- repeated = repeated && (str.charAt(j + i) == str.charAt(j + i + pLen));
- }
- if (j < pLen) {
- repeated = false;
- }
- if (repeated) {
- i += pLen - 1;
- repeated = false;
- }
- else {
- res += str.charAt(i);
- }
- }
- return res;
- };
-
- //password length
- score += password.length * 4;
- score += ( checkRepetition(1, password).length - password.length ) * 1;
- score += ( checkRepetition(2, password).length - password.length ) * 1;
- score += ( checkRepetition(3, password).length - password.length ) * 1;
- score += ( checkRepetition(4, password).length - password.length ) * 1;
-
- //password has 3 numbers
- if (password.match(/(.*[0-9].*[0-9].*[0-9])/)) {
- score += 5;
- }
-
- //password has 2 symbols
- if (password.match(/(.*[!,@,#,$,%,^,&,*,?,_,~].*[!,@,#,$,%,^,&,*,?,_,~])/)) {
- score += 5;
- }
-
- //password has Upper and Lower chars
- if (password.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/)) {
- score += 10;
- }
-
- //password has number and chars
- if (password.match(/([a-zA-Z])/) && password.match(/([0-9])/)) {
- score += 15;
- }
- //
- //password has number and symbol
- if (password.match(/([!,@,#,$,%,^,&,*,?,_,~])/) && password.match(/([0-9])/)) {
- score += 15;
- }
-
- //password has char and symbol
- if (password.match(/([!,@,#,$,%,^,&,*,?,_,~])/) && password.match(/([a-zA-Z])/)) {
- score += 15;
- }
-
- //password is just a numbers or chars
- if (password.match(/^\w+$/) || password.match(/^\d+$/)) {
- score -= 10;
- }
-
- //verifying 0 < score < 100
- if (score < 0) {
- score = 0;
- }
- if (score > 100) {
- score = 100;
- }
-
- if (score < 20) {
- return 0;
- }
- else if (score < 40) {
- return 1;
- }
- else if(score <= 60) {
- return 2;
- }
- else {
- return 3;
- }
- },
-
- strengthDisplay : function($el, options) {
- var config = {
- fontSize: '12pt',
- padding: '4px',
- bad : 'Very bad',
- weak : 'Weak',
- good : 'Good',
- strong : 'Strong'
- };
-
- if (options) {
- $.extend(config, options);
- }
-
- $el.bind('keyup', function() {
- var val = $(this).val();
- var $parent = typeof config.parent == 'undefined' ? $(this).parent() : $(config.parent);
- var $displayContainer = $parent.find('.strength-meter');
- if($displayContainer.length == 0) {
- $displayContainer = $(' ');
- $displayContainer
- .addClass('strength-meter')
- .appendTo($parent);
- }
-
- if( !val ) {
- $displayContainer.hide();
- } else {
- $displayContainer.show();
- }
-
- var strength = $.formUtils.validators.validate_strength.calculatePasswordStrength(val);
- var css = {
- background: 'pink',
- color : '#FF0000',
- fontWeight : 'bold',
- border : 'red solid 1px',
- borderWidth : '0px 0px 4px',
- display : 'inline-block',
- fontSize : config.fontSize,
- padding : config.padding
- };
-
- var text = config.bad;
-
- if(strength == 1) {
- text = config.weak;
- }
- else if(strength == 2) {
- css.background = 'lightyellow';
- css.borderColor = 'yellow';
- css.color = 'goldenrod';
- text = config.good;
- }
- else if(strength >= 3) {
- css.background = 'lightgreen';
- css.borderColor = 'darkgreen';
- css.color = 'darkgreen';
- text = config.strong;
- }
-
-
- $displayContainer
- .css(css)
- .text(text);
- });
- }
- });
-
- var requestServer = function(serverURL, $element, val, conf, callback) {
- $.ajax({
- url : serverURL,
- type : 'POST',
- cache : false,
- data : $element.attr('name')+'='+val,
- dataType : 'json',
- success : function(response) {
-
- if(response.valid) {
- $element.valAttr('backend-valid', 'true');
- }
- else {
- $element.valAttr('backend-invalid', 'true');
- if(response.message)
- $element.attr(conf.validationErrorMsgAttribute, response.message);
- else
- $element.removeAttr(conf.validationErrorMsgAttribute);
- }
-
- if( !$element.valAttr('has-keyup-event') ) {
- $element
- .valAttr('has-keyup-event', '1')
- .bind('keyup', function(evt) {
- if( evt.keyCode != 9 && evt.keyCode != 16 ) {
- $(this)
- .valAttr('backend-valid', false)
- .valAttr('backend-invalid', false)
- .removeAttr(conf.validationErrorMsgAttribute);
- }
- });
- }
-
- callback();
- }
- });
- },
- disableFormSubmit = function() {
- return false;
- };
-
- /*
- * Server validation
- * Flow (form submission):
- * 1) Check if the value already has been validated on the server. If so, display the validation
- * result and continue the validation process, otherwise continue to step 2
- * 2) Return false as if the value is invalid and set $.formUtils.haltValidation to true
- * 3) Disable form submission on the form being validated
- * 4) Request the server with value and input name and add class 'validating-server-side' to the form
- * 5) When the server responds an attribute will be added to the element
- * telling the validator that the input has a valid/invalid value and enable form submission
- * 6) Run form submission again (back to step 1)
- */
- $.formUtils.addValidator({
- name : 'server',
- validatorFunction : function(val, $el, conf, lang, $form) {
-
- var backendValid = $el.valAttr('backend-valid'),
- backendInvalid = $el.valAttr('backend-invalid'),
- serverURL = document.location.href;
-
- if($el.valAttr('url')) {
- serverURL = $el.valAttr('url');
- } else if('serverURL' in conf) {
- serverURL = conf.backendUrl;
- }
-
- if(backendValid)
- return true;
- else if(backendInvalid)
- return false;
-
- if($.formUtils.isValidatingEntireForm) {
- $form
- .bind('submit', disableFormSubmit)
- .addClass('validating-server-side')
- .addClass('on-blur');
-
- $el.addClass('validating-server-side');
-
- requestServer(serverURL, $el, val, conf, function() {
- $form
- .removeClass('validating-server-side')
- .removeClass('on-blur')
- .get(0).onsubmit = function() {};
-
- $form.unbind('submit', disableFormSubmit);
- $el.removeClass('validating-server-side');
-
- // fire submission again!
- $form.trigger('submit');
- });
-
- $.formUtils.haltValidation = true;
- return false;
-
- } else {
- // validaiton on blur
- $form.addClass('validating-server-side');
- $el.addClass('validating-server-side');
- requestServer(serverURL, $el, val, conf, function() {
- $form.removeClass('validating-server-side');
- $el.removeClass('validating-server-side');
- $el.trigger('blur');
- });
- return true;
- }
- },
- errorMessage : '',
- errorMessageKey: 'badBackend',
- validateOnKeyUp : false
- });
-
- $.fn.displayPasswordStrength = function(conf) {
- new $.formUtils.validators.validate_strength.strengthDisplay(this, conf);
- return this;
- };
-
-})(jQuery);
diff --git a/form-validator/security.js b/form-validator/security.js
deleted file mode 100644
index c829266..0000000
--- a/form-validator/security.js
+++ /dev/null
@@ -1 +0,0 @@
-(function($){$.formUtils.addValidator({name:"spamcheck",validatorFunction:function(val,$el,config){var attr=$el.valAttr("captcha");return attr===val},errorMessage:"",errorMessageKey:"badSecurityAnswer"});$.formUtils.addValidator({name:"confirmation",validatorFunction:function(value,$el,config,language,$form){var conf="",confInputName=$el.attr("name")+"_confirmation",confInput=$form.find('input[name="'+confInputName+'"]').eq(0);if(confInput){conf=confInput.val()}else{console.warn('Could not find an input with name "'+confInputName+'"')}return value===conf},errorMessage:"",errorMessageKey:"notConfirmed"});$.formUtils.addValidator({name:"strength",validatorFunction:function(val,$el,conf){var requiredStrength=$el.valAttr("strength");if(requiredStrength&&requiredStrength>3)requiredStrength=3;return $.formUtils.validators.validate_strength.calculatePasswordStrength(val)>=requiredStrength},errorMessage:"",errorMessageKey:"badStrength",calculatePasswordStrength:function(password){if(password.length<4){return 0}var score=0;var checkRepetition=function(pLen,str){var res="";for(var i=0;i100){score=100}if(score<20){return 0}else if(score<40){return 1}else if(score<=60){return 2}else{return 3}},strengthDisplay:function($el,options){var config={fontSize:"12pt",padding:"4px",bad:"Very bad",weak:"Weak",good:"Good",strong:"Strong"};if(options){$.extend(config,options)}$el.bind("keyup",function(){var val=$(this).val();var $parent=typeof config.parent=="undefined"?$(this).parent():$(config.parent);var $displayContainer=$parent.find(".strength-meter");if($displayContainer.length==0){$displayContainer=$(" ");$displayContainer.addClass("strength-meter").appendTo($parent)}if(!val){$displayContainer.hide()}else{$displayContainer.show()}var strength=$.formUtils.validators.validate_strength.calculatePasswordStrength(val);var css={background:"pink",color:"#FF0000",fontWeight:"bold",border:"red solid 1px",borderWidth:"0px 0px 4px",display:"inline-block",fontSize:config.fontSize,padding:config.padding};var text=config.bad;if(strength==1){text=config.weak}else if(strength==2){css.background="lightyellow";css.borderColor="yellow";css.color="goldenrod";text=config.good}else if(strength>=3){css.background="lightgreen";css.borderColor="darkgreen";css.color="darkgreen";text=config.strong}$displayContainer.css(css).text(text)})}});var requestServer=function(serverURL,$element,val,conf,callback){$.ajax({url:serverURL,type:"POST",cache:false,data:$element.attr("name")+"="+val,dataType:"json",success:function(response){if(response.valid){$element.valAttr("backend-valid","true")}else{$element.valAttr("backend-invalid","true");if(response.message)$element.attr(conf.validationErrorMsgAttribute,response.message);else $element.removeAttr(conf.validationErrorMsgAttribute)}if(!$element.valAttr("has-keyup-event")){$element.valAttr("has-keyup-event","1").bind("keyup",function(evt){if(evt.keyCode!=9&&evt.keyCode!=16){$(this).valAttr("backend-valid",false).valAttr("backend-invalid",false).removeAttr(conf.validationErrorMsgAttribute)}})}callback()}})},disableFormSubmit=function(){return false};$.formUtils.addValidator({name:"server",validatorFunction:function(val,$el,conf,lang,$form){var backendValid=$el.valAttr("backend-valid"),backendInvalid=$el.valAttr("backend-invalid"),serverURL=document.location.href;if($el.valAttr("url")){serverURL=$el.valAttr("url")}else if("serverURL"in conf){serverURL=conf.backendUrl}if(backendValid)return true;else if(backendInvalid)return false;if($.formUtils.isValidatingEntireForm){$form.bind("submit",disableFormSubmit).addClass("validating-server-side").addClass("on-blur");$el.addClass("validating-server-side");requestServer(serverURL,$el,val,conf,function(){$form.removeClass("validating-server-side").removeClass("on-blur").get(0).onsubmit=function(){};$form.unbind("submit",disableFormSubmit);$el.removeClass("validating-server-side");$form.trigger("submit")});$.formUtils.haltValidation=true;return false}else{$form.addClass("validating-server-side");$el.addClass("validating-server-side");requestServer(serverURL,$el,val,conf,function(){$form.removeClass("validating-server-side");$el.removeClass("validating-server-side");$el.trigger("blur")});return true}},errorMessage:"",errorMessageKey:"badBackend",validateOnKeyUp:false});$.fn.displayPasswordStrength=function(conf){new $.formUtils.validators.validate_strength.strengthDisplay(this,conf);return this}})(jQuery);
\ No newline at end of file
diff --git a/form-validator/sweden.dev.js b/form-validator/sweden.dev.js
deleted file mode 100644
index e29c3d2..0000000
--- a/form-validator/sweden.dev.js
+++ /dev/null
@@ -1,210 +0,0 @@
-/**
- * jQuery Form Validator Module: Security
- * ------------------------------------------
- * Created by Victor Jonsson
- *
- * This form validation module adds validators typically used on swedish
- * websites. This module adds the following validators:
- * - validate_swesec (Social security number)
- * - validate_swemobile
- * - validate_validate_municipality
- * - validate_county
- * - validate_swephone
- *
- * @website http://formvalidator.net/#swedish-validators
- * @license Dual licensed under the MIT or GPL Version 2 licenses
- * @version 2.1.47
- */
-(function($, window) {
-
- /*
- * Validate swedish social security number yyyymmddXXXX
- */
- $.formUtils.addValidator({
- name : 'swesec',
- validatorFunction : function(securityNumber, $input) {
-
- var year, month, day, ssnParts;
-
- if( $input.valAttr('use-hyphen') ) {
- ssnParts = securityNumber.split('-');
- if( ssnParts.length != 2 ) {
- return false;
- }
- securityNumber = ssnParts.join('');
- }
-
- if (!securityNumber.match(/^(\d{4})(\d{2})(\d{2})(\d{4})$/)) {
- return false;
- }
-
- year = RegExp.$1;
- month = $.formUtils.parseDateInt(RegExp.$2);
- day = $.formUtils.parseDateInt(RegExp.$3);
-
- window.ssnGender = ( parseInt( (RegExp.$4).substring(2,3) ) % 2 ) === 0 ? 'female':'male';
-
- var months = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
- if (year % 400 === 0 || year % 4 === 0 && year % 100 !== 0) {
- months[1] = 29;
- }
- if (month < 1 || month > 12 || day < 1 || day > months[month - 1]) {
- return false;
- }
-
- securityNumber = securityNumber.substring(2, securityNumber.length);
- var check = '';
- for (var i = 0; i < securityNumber.length; i++) {
- check += ((((i + 1) % 2) + 1)* securityNumber.substring(i, i + 1));
- }
- var checksum = 0;
- for (i = 0; i < check.length; i++) {
- checksum += parseInt(check.substring(i, i + 1),10);
- }
-
- return checksum % 10 === 0;
- },
- errorMessage : '',
- errorMessageKey: 'badSecurityNumber'
- });
-
- $.formUtils.addValidator({
- name : 'swecounty',
- validatorFunction : function(str) {
- str = str.toLowerCase();
- if($.inArray(str, this.counties) == -1) {
- if(str.substr(-3).toLocaleLowerCase() != 'län') {
- return $.inArray(str + 's län', this.counties) > -1;
- }
-
- return false;
- }
- else
- return true;
- },
- errorMessage: '',
- errorMessageKey: 'badCustomVal',
- counties : ['stockholms län',
- 'uppsala län',
- 'södermanlands län',
- 'östergötlands län',
- 'jönköpings län',
- 'kronobergs län',
- 'kalmar län',
- 'gotlands län',
- 'blekinge län',
- 'skåne län',
- 'hallands län',
- 'västra götalands län',
- 'värmlands län',
- 'örebro län',
- 'västmanlands län',
- 'dalarnas län',
- 'gävleborgs län',
- 'västernorrlands län',
- 'jämtlands län',
- 'västerbottens län',
- 'norrbottens län']
- });
-
- $.formUtils.addValidator({
- name : 'swemunicipality',
- validatorFunction : function(str) {
- str = str.toLowerCase();
- if($.inArray(str, this.municipalities) == -1) {
-
- // First check (dont return)
- if(str.substr(-8) == 's kommun') {
- if($.inArray( str.substr(0, str.length-8), this.municipalities ) > -1)
- return true;
- }
-
- // Second check
- if(str.substr(-7) == ' kommun') {
- return $.inArray( str.substr(0, str.length-7), this.municipalities ) > -1;
- }
-
- return false;
- }
- else
- return true;
- },
- errorMessage : '',
- errorMessageKey: 'badCustomVal',
- municipalities : ['ale','alingsås','alvesta','aneby','arboga','arjeplog','arvidsjaur','arvika','askersund','avesta','bengtsfors','berg','bjurholm','bjuv','boden','bollebygd','bollnäs','borgholm','borlänge','borås','botkyrka','boxholm','bromölla','bräcke','burlöv','båstad','dals-ed','danderyd','degerfors','dorotea','eda','ekerö','eksjö','emmaboda','enköpings','eskilstuna','eslövs','essunga','fagersta','falkenberg','falköping','falu','filipstad','finspång','flen','forshaga','färgelanda','gagnef','gislaved','gnesta','gnosjö','gotland','grum','grästorp','gullspång','gällivare','gävle','göteborg','götene','habo','hagfor','hallsberg','hallstahammar','halmstad','hammarö','haninge','haparanda','heby','hedemora','helsingborg','herrljunga','hjo','hofor','huddinge','hudiksvall','hultsfred','hylte','håbo','hällefor','härjedalen','härnösand','härryda','hässleholm','höganäs','högsby','hörby','höör','jokkmokk','järfälla','jönköping','kalix','kalmar','karlsborg','karlshamn','karlskoga','karlskrona','karlstad','katrineholm','kil','kinda','kiruna','klippan','knivsta','kramfors','kristianstad','kristinehamn','krokoms','kumla','kungsbacka','kungsör','kungälv','kävlinge','köping','laholm','landskrona','laxå','lekeberg','leksand','lerum','lessebo','lidingö','lidköping','lilla edets','lindesbergs','linköpings','ljungby','ljusdals','ljusnarsbergs','lomma','ludvika','luleå','lunds','lycksele','lysekil','malmö','malung-sälen','malå','mariestad','marks','markaryd','mellerud','mjölby','mora','motala','mullsjö','munkedal','munkfors','mölndal','mönsterås','mörbylånga','nacka','nora','norberg','nordanstig','nordmaling','norrköping','norrtälje','norsjö','nybro','nykvarn','nyköping','nynäshamn','nässjö','ockelbo','olofström','orsa','orust','osby','oskarshamn','ovanåker','oxelösund','pajala','partille','perstorp','piteå','ragunda','robertsfors','ronneby','rättvik','sala','salem','sandviken','sigtuna','simrishamn','sjöbo','skara','skellefteå','skinnskatteberg','skurup','skövde','smedjebacken','sollefteå','sollentuna','solna','sorsele','sotenäs','staffanstorp','stenungsund','stockholm','storfors','storuman','strängnäs','strömstad','strömsund','sundbyberg','sundsvall','sunne','surahammar','svalöv','svedala','svenljunga','säffle','säter','sävsjö','söderhamns','söderköping','södertälje','sölvesborg','tanum','tibro','tidaholm','tierp','timrå','tingsryd','tjörn','tomelilla','torsby','torså','tranemo','tranå','trelleborg','trollhättan','trosa','tyresö','täby','töreboda','uddevalla','ulricehamns','umeå','upplands väsby','upplands-bro','uppsala','uppvidinge','vadstena','vaggeryd','valdemarsvik','vallentuna','vansbro','vara','varberg','vaxholm','vellinge','vetlanda','vilhelmina','vimmerby','vindeln','vingåker','vårgårda','vänersborg','vännäs','värmdö','värnamo','västervik','västerås','växjö','ydre','ystad','åmål','ånge','åre','årjäng','åsele','åstorp','åtvidaberg','älmhult','älvdalen','älvkarleby','älvsbyn','ängelholm','öckerö','ödeshög','örebro','örkelljunga','örnsköldsvik','östersund','österåker','östhammar','östra göinge','överkalix','övertorneå']
- });
-
-
- /*
- * Validate phone number, at least 7 digits only one hyphen and plus allowed
- */
- $.formUtils.addValidator({
- name : 'swephone',
- validatorFunction : function(tele) {
- var numPlus = tele.match(/\+/g);
- var numHifen = tele.match(/-/g);
-
- if ((numPlus !== null && numPlus.length > 1) || (numHifen !== null && numHifen.length > 1)) {
- return false;
- }
- if (numPlus !== null && tele.indexOf('+') !== 0) {
- return false;
- }
-
- tele = tele.replace(/([-|\+])/g, '');
- return tele.length > 8 && tele.match(/[^0-9]/g) === null;
- },
- errorMessage : '',
- errorMessageKey: 'badTelephone'
- });
-
-
- /*
- * Validate that string is a swedish telephone number
- */
- $.formUtils.addValidator({
- name : 'swemobile',
- validatorFunction : function(number) {
- if (!$.formUtils.validators.validate_swephone.validatorFunction(number)) {
- return false;
- }
-
- number = number.replace(/[^0-9]/g, '');
- var begin = number.substring(0, 3);
-
- if (number.length != 10 && begin !== '467') {
- return false;
- } else if (number.length != 11 && begin === '467') {
- return false;
- }
- return (/07[0-9{1}]/).test(begin) || begin === '467';
- },
- errorMessage : '',
- errorMessageKey: 'badTelephone'
- });
-
- /**
- * @private
- * @param {Array} listItems
- * @return {Array}
- */
- var _makeSortedList = function(listItems) {
- var newList = [];
- $.each(listItems, function(i, v) {
- newList.push(v.substr(0,1).toUpperCase() + v.substr(1, v.length));
- });
- newList.sort();
- return newList;
- };
-
- $.fn.suggestSwedishCounty = function(settings) {
- var counties = _makeSortedList($.formUtils.validators.validate_swecounty.counties);
- return $.formUtils.suggest(this, counties, settings);
- };
-
- $.fn.suggestSwedishMunicipality = function(settings) {
- var municipalities = _makeSortedList($.formUtils.validators.validate_swemunicipality.municipalities);
- return $.formUtils.suggest(this, municipalities, settings);
- };
-
-})(jQuery, window);
\ No newline at end of file
diff --git a/form-validator/sweden.js b/form-validator/sweden.js
deleted file mode 100644
index bdb527a..0000000
--- a/form-validator/sweden.js
+++ /dev/null
@@ -1 +0,0 @@
-(function($,window){$.formUtils.addValidator({name:"swesec",validatorFunction:function(securityNumber,$input){var year,month,day,ssnParts;if($input.valAttr("use-hyphen")){ssnParts=securityNumber.split("-");if(ssnParts.length!=2){return false}securityNumber=ssnParts.join("")}if(!securityNumber.match(/^(\d{4})(\d{2})(\d{2})(\d{4})$/)){return false}year=RegExp.$1;month=$.formUtils.parseDateInt(RegExp.$2);day=$.formUtils.parseDateInt(RegExp.$3);window.ssnGender=parseInt(RegExp.$4.substring(2,3))%2===0?"female":"male";var months=new Array(31,28,31,30,31,30,31,31,30,31,30,31);if(year%400===0||year%4===0&&year%100!==0){months[1]=29}if(month<1||month>12||day<1||day>months[month-1]){return false}securityNumber=securityNumber.substring(2,securityNumber.length);var check="";for(var i=0;i-1}return false}else return true},errorMessage:"",errorMessageKey:"badCustomVal",counties:["stockholms län","uppsala län","södermanlands län","östergötlands län","jönköpings län","kronobergs län","kalmar län","gotlands län","blekinge län","skåne län","hallands län","västra götalands län","värmlands län","örebro län","västmanlands län","dalarnas län","gävleborgs län","västernorrlands län","jämtlands län","västerbottens län","norrbottens län"]});$.formUtils.addValidator({name:"swemunicipality",validatorFunction:function(str){str=str.toLowerCase();if($.inArray(str,this.municipalities)==-1){if(str.substr(-8)=="s kommun"){if($.inArray(str.substr(0,str.length-8),this.municipalities)>-1)return true}if(str.substr(-7)==" kommun"){return $.inArray(str.substr(0,str.length-7),this.municipalities)>-1}return false}else return true},errorMessage:"",errorMessageKey:"badCustomVal",municipalities:["ale","alingsås","alvesta","aneby","arboga","arjeplog","arvidsjaur","arvika","askersund","avesta","bengtsfors","berg","bjurholm","bjuv","boden","bollebygd","bollnäs","borgholm","borlänge","borås","botkyrka","boxholm","bromölla","bräcke","burlöv","båstad","dals-ed","danderyd","degerfors","dorotea","eda","ekerö","eksjö","emmaboda","enköpings","eskilstuna","eslövs","essunga","fagersta","falkenberg","falköping","falu","filipstad","finspång","flen","forshaga","färgelanda","gagnef","gislaved","gnesta","gnosjö","gotland","grum","grästorp","gullspång","gällivare","gävle","göteborg","götene","habo","hagfor","hallsberg","hallstahammar","halmstad","hammarö","haninge","haparanda","heby","hedemora","helsingborg","herrljunga","hjo","hofor","huddinge","hudiksvall","hultsfred","hylte","håbo","hällefor","härjedalen","härnösand","härryda","hässleholm","höganäs","högsby","hörby","höör","jokkmokk","järfälla","jönköping","kalix","kalmar","karlsborg","karlshamn","karlskoga","karlskrona","karlstad","katrineholm","kil","kinda","kiruna","klippan","knivsta","kramfors","kristianstad","kristinehamn","krokoms","kumla","kungsbacka","kungsör","kungälv","kävlinge","köping","laholm","landskrona","laxå","lekeberg","leksand","lerum","lessebo","lidingö","lidköping","lilla edets","lindesbergs","linköpings","ljungby","ljusdals","ljusnarsbergs","lomma","ludvika","luleå","lunds","lycksele","lysekil","malmö","malung-sälen","malå","mariestad","marks","markaryd","mellerud","mjölby","mora","motala","mullsjö","munkedal","munkfors","mölndal","mönsterås","mörbylånga","nacka","nora","norberg","nordanstig","nordmaling","norrköping","norrtälje","norsjö","nybro","nykvarn","nyköping","nynäshamn","nässjö","ockelbo","olofström","orsa","orust","osby","oskarshamn","ovanåker","oxelösund","pajala","partille","perstorp","piteå","ragunda","robertsfors","ronneby","rättvik","sala","salem","sandviken","sigtuna","simrishamn","sjöbo","skara","skellefteå","skinnskatteberg","skurup","skövde","smedjebacken","sollefteå","sollentuna","solna","sorsele","sotenäs","staffanstorp","stenungsund","stockholm","storfors","storuman","strängnäs","strömstad","strömsund","sundbyberg","sundsvall","sunne","surahammar","svalöv","svedala","svenljunga","säffle","säter","sävsjö","söderhamns","söderköping","södertälje","sölvesborg","tanum","tibro","tidaholm","tierp","timrå","tingsryd","tjörn","tomelilla","torsby","torså","tranemo","tranå","trelleborg","trollhättan","trosa","tyresö","täby","töreboda","uddevalla","ulricehamns","umeå","upplands väsby","upplands-bro","uppsala","uppvidinge","vadstena","vaggeryd","valdemarsvik","vallentuna","vansbro","vara","varberg","vaxholm","vellinge","vetlanda","vilhelmina","vimmerby","vindeln","vingåker","vårgårda","vänersborg","vännäs","värmdö","värnamo","västervik","västerås","växjö","ydre","ystad","åmål","ånge","åre","årjäng","åsele","åstorp","åtvidaberg","älmhult","älvdalen","älvkarleby","älvsbyn","ängelholm","öckerö","ödeshög","örebro","örkelljunga","örnsköldsvik","östersund","österåker","östhammar","östra göinge","överkalix","övertorneå"]});$.formUtils.addValidator({name:"swephone",validatorFunction:function(tele){var numPlus=tele.match(/\+/g);var numHifen=tele.match(/-/g);if(numPlus!==null&&numPlus.length>1||numHifen!==null&&numHifen.length>1){return false}if(numPlus!==null&&tele.indexOf("+")!==0){return false}tele=tele.replace(/([-|\+])/g,"");return tele.length>8&&tele.match(/[^0-9]/g)===null},errorMessage:"",errorMessageKey:"badTelephone"});$.formUtils.addValidator({name:"swemobile",validatorFunction:function(number){if(!$.formUtils.validators.validate_swephone.validatorFunction(number)){return false}number=number.replace(/[^0-9]/g,"");var begin=number.substring(0,3);if(number.length!=10&&begin!=="467"){return false}else if(number.length!=11&&begin==="467"){return false}return/07[0-9{1}]/.test(begin)||begin==="467"},errorMessage:"",errorMessageKey:"badTelephone"});var _makeSortedList=function(listItems){var newList=[];$.each(listItems,function(i,v){newList.push(v.substr(0,1).toUpperCase()+v.substr(1,v.length))});newList.sort();return newList};$.fn.suggestSwedishCounty=function(settings){var counties=_makeSortedList($.formUtils.validators.validate_swecounty.counties);return $.formUtils.suggest(this,counties,settings)};$.fn.suggestSwedishMunicipality=function(settings){var municipalities=_makeSortedList($.formUtils.validators.validate_swemunicipality.municipalities);return $.formUtils.suggest(this,municipalities,settings)}})(jQuery,window);
\ No newline at end of file
diff --git a/form-validator/uk.dev.js b/form-validator/uk.dev.js
deleted file mode 100644
index 5f32101..0000000
--- a/form-validator/uk.dev.js
+++ /dev/null
@@ -1,85 +0,0 @@
-/**
- * jQuery Form Validator Module: Security
- * ------------------------------------------
- * Created by Victor Jonsson
- *
- * This form validation module adds validators typically used on
- * websites in the UK. This module adds the following validators:
- * - ukvatnumber
- *
- * @website http://formvalidator.net/#uk-validators
- * @license Dual licensed under the MIT or GPL Version 2 licenses
- * @version 2.1.47
- */
-$.formUtils.addValidator({
- name : 'ukvatnumber',
- validatorFunction : function(number) {
-
- // Code Adapted from http://www.codingforums.com/showthread.php?t=211967
- // TODO: Extra Checking for other VAT Numbers (Other countries and UK Government/Health Authorities)
-
- number = number.replace(/[^0-9]/g, '');
-
- //Check Length
- if(number.length < 9) {
- return false;
- }
-
- var valid = false;
-
- var VATsplit = [];
- VATsplit = number.split("");
-
- var checkDigits = Number(VATsplit[7] + VATsplit[8]); // two final digits as a number
-
- var firstDigit = VATsplit[0];
- var secondDigit = VATsplit[1];
- if ((firstDigit == 0) && (secondDigit >0)) {
- return false;
- }
-
- var total = 0;
- for (var i=0; i<7; i++) { // first 7 digits
- total += VATsplit[i]* (8-i); // sum weighted cumulative total
- }
-
- var c = 0;
- var i = 0;
-
- for (var m = 8; m>=2; m--) {
- c += VATsplit[i]* m;
- i++;
- }
-
- // Traditional Algorithm for VAT numbers issued before 2010
-
- while (total > 0) {
- total -= 97; // deduct 97 repeatedly until total is negative
- }
- total = Math.abs(total); // make positive
-
- if (checkDigits == total) {
- valid = true;
- }
-
- // If not valid try the new method (introduced November 2009) by subtracting 55 from the mod 97 check digit if we can - else add 42
-
- if (!valid) {
- total = total%97 // modulus 97
-
- if (total >= 55) {
- total = total - 55
- } else {
- total = total + 42
- }
-
- if (total == checkDigits) {
- valid = true;
- }
- }
-
- return valid;
- },
- errorMessage : '',
- errorMessageKey: 'badUKVatAnswer'
-});
diff --git a/form-validator/uk.js b/form-validator/uk.js
deleted file mode 100644
index eeab7cc..0000000
--- a/form-validator/uk.js
+++ /dev/null
@@ -1 +0,0 @@
-$.formUtils.addValidator({name:"ukvatnumber",validatorFunction:function(number){number=number.replace(/[^0-9]/g,"");if(number.length<9){return false}var valid=false;var VATsplit=[];VATsplit=number.split("");var checkDigits=Number(VATsplit[7]+VATsplit[8]);var firstDigit=VATsplit[0];var secondDigit=VATsplit[1];if(firstDigit==0&&secondDigit>0){return false}var total=0;for(var i=0;i<7;i++){total+=VATsplit[i]*(8-i)}var c=0;var i=0;for(var m=8;m>=2;m--){c+=VATsplit[i]*m;i++}while(total>0){total-=97}total=Math.abs(total);if(checkDigits==total){valid=true}if(!valid){total=total%97;if(total>=55){total=total-55}else{total=total+42}if(total==checkDigits){valid=true}}return valid},errorMessage:"",errorMessageKey:"badUKVatAnswer"});
\ No newline at end of file
diff --git a/formvalidator.jquery.json b/formvalidator.jquery.json
deleted file mode 100644
index f2af52a..0000000
--- a/formvalidator.jquery.json
+++ /dev/null
@@ -1,27 +0,0 @@
-{
- "name" : "formvalidator",
- "title" : "jQuery Form Validator",
- "description" : "This plugin 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 bandwidth as possible. This is achieved by grouping together validation functions in \"modules\", making it possible for the programmer to load only those functions that's needed to validate a particular form.",
- "keywords": [
- "form",
- "validation",
- "validator"
- ],
- "version" : "2.1.47",
- "author" : {
- "name": "Victor Jonsson",
- "url": "http://victorjonsson.se",
- "email" : "kontakt@victorjonsson.se"
- },
- "homepage" : "http://formvalidator.net",
- "demo" : "http://formvalidator.net",
- "download" : "http://formvalidator.net",
- "bugs" : "https://github.com/victorjonsson/jQuery-Form-Validator/issues",
- "licenses" : [{
- "type": "Dual licensed under the MIT or GPL Version 2 licenses",
- "url": "http://www.gnu.org/licenses/gpl-2.0.html"
- }],
- "dependencies" : {
- "jquery": ">=1.5"
- }
-}
From 5a5a6d7c6900f8ccf3cc010671fc627dda0bfbec Mon Sep 17 00:00:00 2001
From: mbigatti
Date: Tue, 11 Mar 2014 14:06:45 +0100
Subject: [PATCH 2/3] minor revision
---
README.md | 27 +++++++++++++++++--
...m-validator.js => jquery.form-validator.js | 0
2 files changed, 25 insertions(+), 2 deletions(-)
rename form-validator/jquery.form-validator.js => jquery.form-validator.js (100%)
diff --git a/README.md b/README.md
index 44de47f..874fd2e 100644
--- a/README.md
+++ b/README.md
@@ -16,6 +16,29 @@ This version:
## Credits
-#### Maintainer
+Maintainer of original branch: [Victor Jonsson](https://github.com/victorjonsson)
-[Victor Jonsson](https://github.com/victorjonsson)
+## License
+
+This code is licensed under the MIT license.
+
+### MIT License
+Copyright (c) 2014 Massimiliano Bigatti (http://bigatti.it)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/form-validator/jquery.form-validator.js b/jquery.form-validator.js
similarity index 100%
rename from form-validator/jquery.form-validator.js
rename to jquery.form-validator.js
From 7e7abc8f7026e71268ad708e31b599c8f74c3ee1 Mon Sep 17 00:00:00 2001
From: mbigatti
Date: Tue, 11 Mar 2014 14:07:14 +0100
Subject: [PATCH 3/3] Delete .gitignore
---
.gitignore | 3 ---
1 file changed, 3 deletions(-)
delete mode 100644 .gitignore
diff --git a/.gitignore b/.gitignore
deleted file mode 100644
index bf8f782..0000000
--- a/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-.DS_Store
-
-_old/
\ No newline at end of file