diff --git a/README.md b/README.md
index ca0d515..e6979f9 100644
--- a/README.md
+++ b/README.md
@@ -120,9 +120,14 @@ Read the documentation for the Swedish module at [http://formvalidator.net/#swed
Read the documentation for the UK module at [http://formvalidator.net/#uk-validators](http://formvalidator.net/#uk-validators)
### Module: brazil
- * **brphone** — Validate a brazilian telephone number
+ * **brphone** — *Validate a brazilian telephone number*
* **cep**
* **cpf**
+
+### Module: poland
+ * **plpesel** - *validate polish personal identity number (in Polish identity cards)*
+ * **plnip** - *validate polish VAT identification number*
+ * **plregon** - *validate polish bussiness identity number*
### Module: sanitation
* **trim**
diff --git a/src/lang/pl.js b/src/lang/pl.js
index ea1ebfe..811cd4c 100644
--- a/src/lang/pl.js
+++ b/src/lang/pl.js
@@ -58,7 +58,10 @@
imageRatioNotAccepted: 'Proporcje obrazu są niepoprawne',
badBrazilTelephoneAnswer: 'Wprowadzono niepoprawny numer telefonu',
badBrazilCEPAnswer: 'Wprowadzono niepoprawny CEP',
- badBrazilCPFAnswer: 'Wprowadzono niepoprawny CPF'
+ badBrazilCPFAnswer: 'Wprowadzono niepoprawny CPF',
+ badPlPesel: 'Wprowadzono niepoprawny numer PESEL',
+ badPlNip: 'Wprowadzono niepoprawny numer NIP',
+ badPlRegon: 'Wprowadzono niepoprawny numer REGON'
};
});
diff --git a/src/main/utils.js b/src/main/utils.js
index 550465f..bb62c65 100644
--- a/src/main/utils.js
+++ b/src/main/utils.js
@@ -825,7 +825,10 @@
imageRatioNotAccepted : 'Image ratio is not be accepted',
badBrazilTelephoneAnswer: 'The phone number entered is invalid',
badBrazilCEPAnswer: 'The CEP entered is invalid',
- badBrazilCPFAnswer: 'The CPF entered is invalid'
+ badBrazilCPFAnswer: 'The CPF entered is invalid',
+ badPlPesel: 'The PESEL entered is invalid',
+ badPlNip: 'The NIP entered is invalid',
+ badPlRegon: 'The REGON entered is invalid'
}
});
diff --git a/src/modules/poland.js b/src/modules/poland.js
new file mode 100644
index 0000000..aa15954
--- /dev/null
+++ b/src/modules/poland.js
@@ -0,0 +1,115 @@
+/**
+ * jQuery Form Validator Module: Poland
+ * ------------------------------------------
+ * Created by simivar
+ *
+ * This form validation module adds validators typically used on
+ * websites in Poland. This module adds the following validators:
+ * - plpesel
+ *
+ * @website http://formvalidator.net/#poland-validators
+ * @license MIT
+ */
+(function($) {
+
+ /**
+ * PL PESEL - polish personal identity number (in Polish identity cards) validator
+ */
+ $.formUtils.addValidator({
+ name: 'plpesel',
+ validatorFunction: function(pesel){
+ var weights = [1, 3, 7, 9, 1, 3, 7, 9, 1, 3],
+ checkSum = 0, checkDigit = 0;
+
+ if( /\d{11}/.test( pesel ) && pesel.length === 11 ){
+ for (var i = 0; i < 10; i++) {
+ checkSum += pesel[ i ] * weights[ i ];
+ }
+
+ if( checkSum % 10 !== 0 ){
+ checkDigit = 10 - (checkSum % 10);
+ }
+
+ if( parseInt( pesel.charAt( 10 ) ) === checkDigit ){
+ return true;
+ }
+ }
+
+ return false;
+ },
+ errorMessage: '',
+ errorMessageKey: 'badPlPesel'
+ });
+
+ /**
+ * PL NIP - polish VAT identification number validator
+ */
+ $.formUtils.addValidator({
+ name: 'plnip',
+ validatorFunction: function(nip){
+ var weights = [6, 5, 7, 2, 3, 4, 5, 6, 7],
+ checkSum = 0;
+
+ if( /\d{10}/.test( nip ) && nip.length === 10 ){
+ for (var i = 0; i < 9; i++) {
+ checkSum += nip[ i ] * weights[ i ];
+ }
+
+ if( parseInt( nip.charAt( 9 ) ) === checkSum % 11 ){
+ return true;
+ }
+ }
+
+ return false;
+ },
+ errorMessage: '',
+ errorMessageKey: 'badPlNip'
+ });
+
+ /**
+ * PL REGON - polish bussiness identity number validator
+ */
+ $.formUtils.addValidator({
+ name: 'plregon',
+ validatorFunction: function(regon){
+ var weightsNine = [8, 9, 2, 3, 4, 5, 6, 7],
+ weightsFourteen = [2, 4, 8, 5, 0, 9, 7, 3, 6, 1, 2, 4, 8],
+ checkSum = 0, checkDigit = 0;
+
+ if( /(\d{14}|\d{9})/.test( regon ) && ( regon.length === 9 || regon.length === 14 ) ){
+ for (var i = 0; i < 8; i++) {
+ checkSum += regon[ i ] * weightsNine[ i ];
+ }
+
+ if( checkSum % 11 !== 10 ){
+ checkDigit = checkSum % 11;
+ }
+
+ if( parseInt( regon.charAt( 8 ) ) === checkDigit ){
+ if( regon.length === 14 ){
+ checkSum = 0;
+
+ for (i = 0; i < 13; i++) {
+ checkSum += regon[ i ] * weightsFourteen[ i ];
+ }
+
+ if( checkSum % 11 !== 10 ){
+ checkDigit = checkSum % 11;
+ }
+
+ if( parseInt( regon.charAt( 13 ) ) === checkDigit ){
+ return true;
+ }
+ } else {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ },
+ errorMessage: '',
+ errorMessageKey: 'badPlRegon'
+ });
+
+})(jQuery);
\ No newline at end of file
diff --git a/test/form.html b/test/form.html
index 0f3e308..966b7c9 100644
--- a/test/form.html
+++ b/test/form.html
@@ -101,7 +101,7 @@
data-validation-ignore="$€"
data-validation-allowing="range[0;10], float"
data-validation-decimal-separator=","
- />
+ />
@@ -184,7 +184,7 @@
data-validation="extension required"
data-validation-error-msg="You must write a file name with extension jpg|png|ico"
data-validation-allowing="jpg, png, ico"
- />
+ />
-
+
@@ -278,19 +278,19 @@
+ data-validation="alphanumeric"
+ data-validation-error-msg="Invalid above..."
+ data-validation-depends-on="checker" />
Checkbox
+ data-validation="alphanumeric"
+ data-validation-error-msg="Invalid below..."
+ data-validation-depends-on="checker"
+ data-validation-depends-on-value="99" />
@@ -368,103 +368,124 @@
Validation Module: Brazil
+
+