jQuery validation polish
Additional methods for jquery validation library specific to polish websites. More info about jQuery Validation and docs for usage and options: jQuery Validation
Demo
Demo files showing basic plugin usage and some of methods is shown in demo
directory.
Usage
You can use additional methods provided by this plugin in few ways. If you use date validators please include date.js libarary. They rely on date functions provided by this lib.
Method 1 - for prototyping, not recommended for production
Use unpkg CDN. Latest version library is available under this link: https://unpkg.com/@divantespzoo/jquery-validation-polish/dist/jquery.validation.polish.js
Before loading this methods you should load jquery and jquery validation. Example:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js" defer></script>
<script src="https://cdn.jsdelivr.net/jquery.validation/1.16.0/jquery.validate.min.js" defer></script>
<script src="https://unpkg.com/@divantespzoo/jquery-validation-polish/dist/jquery.validation.polish.js" defer></script>
Method 2 - with build system
First install npm module using of the command below:
npm install @divantespzoo/jquery-validation-polish --save
or with Yarn
yarn add @divantespzoo/jquery-validation-polish
If you want to include all available methods in your file after importing jQuery and jQuery validation import following package:
import '@divantespzoo/jquery-validation-polish';
When you need only couple of methods import each one explicitly. You will avoid having unused code in your production files. This method requires your build system to transpile JS for ES5 standard.
Example for address validation:
import '@divantespzoo/jquery-validation-polish/validatorAddress';
Below in each method description import path will be specified.
Available methods
Address
Allows for letters (including polish and german diacritics), digits, white space and special characters: \/,.-"
Class: `js-validation-address`
Default message: `Wprowad藕 poprawnie adres.`
Import file: `validatorAddress`
Alpha characters with polish and german diacritics
Allow only letters (including polish and german diacritics)
Class: `js-validation-alpha-pl-de`
Default message: `Dozwolone s膮 tylko litery.`
Import file: `validatorAlphaPlDe`
Alpha characters with polish diacritics
Allow only letters (including polish diacritics)
Class: `js-validation-alpha-pl`
Default message: `Dozwolone s膮 tylko litery od a do z.`
Import file: `validatorAlphaPl`
Alpha characters
Allow only letters
Class: `js-validation-alpha`
Default message: `Dozwolone s膮 tylko litery od a do z bez polskich znak贸w.`
Import file: `validatorAlpha`
Building number
Requires at least 1 number that can be followed by letters, digits, special characters and whitespace.
Class: `js-validation-building-number`
Default message: `Wprowad藕 poprawnie numer budynku.`
Import file: `validatorBuildingNumber`
City
Requires at 2 letters and then allows for whitespace, special characters like - and more letters
Class: `js-validation-city`
Default message: `Wprowad藕 poprawnie nazw臋 miasta.`
Import file: `validatorCity`
Date
Checks if date is correct. Format for date is yyyy-mm-dd. Parts of date can be separated with -\/._
Class: `js-validation-date`
Default message: `Wprowad藕 poprawn膮 dat臋`
Import file: `validatorDate`
Date from future
Checks if date is correct and if it is from future. Present date is incorrect.
Class: `js-validation-date-future`
Default message: `Data musi by膰 z przysz艂o艣ci.`
Import file: `validatorDateFuture`
Prerequisite: method requires date validator. Import it before this one
Date max
Checks if date happened before provided max value.
Default message: `Prosz臋 wprowadzi膰 dat臋 przed ${max}`
Import file: `validatorDateMax`
Recommendation: use date validator to check id date is correct.
Parameters: max date
Date min
Checks if date happened after provided min value.
Default message: `Prosz臋 wprowadzi膰 dat臋 po ${min}`
Import file: `validatorDateMin`
Recommendation: use date validator to check id date is correct.
Parameters: min date
Date not future
Check if date is correct and is not from future(today or past).
Class: `js-validation-date-not-future`
Default message: `Data nie mo偶e by膰 z przysz艂o艣ci.`
Import file: `validatorDateNotFuture`
Prerequisite: method requires date validator. Import it before this one
Date not past
Check if date is correct and is not from past(today or future).
Class: `js-validation-date-not-past`
Default message: `Data nie mo偶e by膰 z przesz艂o艣ci.`
Import file: `validatorDateNotPast`
Prerequisite: method requires date validator. Import it before this one
Date past
Check if date is correct and is from past (not present).
Class: `js-validation-date-past`
Default message: `Data musi by膰 z przesz艂o艣ci.`
Import file: `validatorDatePast`
Prerequisite: method requires date validator. Import it before this one
Digits
Checks if string contains only digits.
Class: `js-validation-digits`
Default message: `Dozwolone s膮 tylko cyfry.`
Import file: `validatorDigits`
Overrides jQuery validation email validator. Limits string to 320 chars.
Class: `js-validation-email`
Default message: `Wprowad藕 poprawny adres email.`
Import file: `validatorEmail`
Firstname
Enables Alpha characters with polish and german diacritics validator
Class: `js-validation-firstname`
Default message: same as used in enabled validator
Import file: `validatorFirstname`
Prerequisite: method requires Alpha characters with polish and german diacritics validator. Import it before this one
Firstnames with Lastname
Requires at least one name and lastname. Blocks most of special characters and digits.
Class: `js-validation-firstnames-lastname`
Default message: `Wprowad藕 poprawnie imi臋/imiona i nazwisko.`
Import file: `validatorFirstnamesLastname`
Firstnames
Requires at least one name. Blocks most of special characters and digits.
Class: `js-validation-firstnames`
Default message: `Wprowad藕 poprawnie imi臋/imiona`
Import file: `validatorFirstnames`
Fullname
Requires firstname and lastname. Blocks most of special characters and digits.
Class: `js-validation-fullname`
Default message: `Wprowad藕 poprawnie imi臋 i nazwisko`
Import file: `validatorFullname`
Lastname
Requires lastname. Blocks most of special characters and digits.
Class: `js-validation-lastname`
Default message: `Wprowad藕 poprawnie nazwisko`
Import file: `validatorLastname`
House number
Requires at least one digits. Then it allows for more digits, alpha characters and some special characters -/\
Class: `js-validation-house-number`
Default message: `Wprowad藕 poprawnie numer mieszkania.`
Import file: `validatorHouseNumber`
KRS
Requires 10 digits
Class: `js-validation-krs`
Default message: `Podaj poprawny numer KRS.`
Import file: `validatorKRS`
Max checked
Allows for only max checked items from form.
Class: `js-validation-max-checked`
Default message: `Prosz臋 zaznaczy膰 maksymalnie ${maxChecked} p贸l.`
Import file: `validatorMaxChecked`
Parameters: Provide maximum amount of checked checkboxes in attribute `data-js-validation-max-checked`
Max words
Requires input to have less than max words. Words are seprated with whitespace
Class: `js-validation-max-words`
Default message: `Wprowad藕 maksymalnie ${max} wyraz贸w.`
Import file: `validatorMaxWords`
Max length
Overrides maxlength validator with custom message
Default message: `Wprowad藕 maksymalnie ${max} znak贸w.`
Import file: `validatorMaxlength`
Min checked
Allow for at least min checked items from form.
Class: `js-validation-min-checked`
Default message: `Prosz臋 zaznaczy膰 przynajmniej ${minChecked} p贸l.`
Import file: `validatorMinChecked`
Parameters: Provide minimum of checked checkboxes in attribute `data-js-validation-min-checked`
Min words
Requires input to have at least min words. Words are seprated with whitespace
Class: `js-validation-min-words`
Default message: `Wprowad藕 przynajmniej ${min} wyraz贸w.`
Import file: `validatorMinWords`
Min length
Overrides minlength validator with custom message
Default message: `Wprowad藕 przynajmniej ${min} znak贸w.`
Import file: `validatorMinlength`
NIP
Checkes if number is correct NIP code
Class: `js-validation-nip`
Default message: `Prosz臋 wpisa膰 poprawny numer NIP`
Import file: `validatiorNIP`
Number between min and max
Checks if number is correct and if between min and max
Default message: `Prosz臋 wpisa膰 warto艣膰 pomi臋dzy ${min} i ${max}.`
Import file: `validatorNumberBetween`
Parameters: min value, max value
Number integer
Checks if number is integer
Class: `js-validation-number-integer`
Default message: `Prosz臋 wpisa膰 liczb臋 ca艂kowit膮.`
Import file: `validatorNumberInteger`
Number max
Checks if number is less or equals to max
Default message: `Prosz臋 wpisa膰 warto艣膰 mniejsz膮 lub r贸wn膮 ${max}.`
Import file: `validatorNumberMax`
Parameters: max value
Number min
Checks if number is more or equal to min
Default message: `Prosz臋 wpisa膰 warto艣膰 wi臋ksz膮 lub r贸wn膮 ${min}.
Import file: `validatorNumberMin`
Parameters: min value
Number not negative
Checks if number is equals or more than 0
Class: `js-validation-number-not-negative`
Default message: `Prosz臋 wpisa膰 poprawn膮 liczb臋.`
Import file: `validatorNumberNotNegative`
Number positive
Checks if number is bigger than 0
Class: `js-validation-number-positive`
Default message: `Prosz臋 wpisa膰 poprawn膮 liczb臋.`
Import file: `validatorNumberPositive`
Number
Checks if value is correct number
Class: `js-validation-number`
Default message: `Prosz臋 wpisa膰 poprawn膮 liczb臋.`
Import file: `validatorNumber`
PESEL
Checks if value is correct PESEL code
Class: `js-validation-pesel`
Default message: `Prosz臋 wpisa膰 poprawny numer PESEL`
Import file: `validatorPESEL`
Phone
Checks if value is correct phone number
Class: `js-validation-phone`
Default message: `Podaj poprawny numer telefonu.`
Import file: `validatorPhone`
Postal code
Checks if value is in polish postal format
Class: `js-validation-postal-code`
Default message: `Wprowad藕 poprawnie kod pocztowy.`
Import file: `validatorPostalCode`
Range checked
Checks if checkboxes number between min and max was checked in form
Class: `js-validation-range-checked`
Default message: `Prosz臋 zaznaczy膰 od ${min} do ${max} p贸l.`
Import file: `validatorRangeChecked`
Parameters: min checked amount in `data-js-validation-min-checked` and max checked amount in `data-js-validation-max-checked`
Range length
Overrides message for length check of input between min and max
Default message: `Wprowad藕 od ${min} do ${max} znak贸w.`
Import file: `validatorRangeLength`
Range words
Checks if words count is between min and max
Default message: `Wprowad藕 od ${min} do ${max} wyraz贸w.`
Import file: `validatorRangeWords`
Parameters: min amount, max amount
REGON
Checks if value is correct REGON code
Class: `js-validation-regon`
Default message: `Podaj poprawny REGON.`
Import file: `validatorREGON`
Repeat email
Checks if two fields represent same email address
Default message: `Adresy email si臋 nie zgadzaj膮.`
Import file: `validatorRepeatEmail`
Parameters: jQuery element pointing other email field
Repeat field
Checks if two fields have the exact same values
Default message: `Pola si臋 nie zgadzaj膮.`
Import file: `validatorRepeatField`
Parameters: jQuery element pointing other field
Require from group
Checks if at least min amount of field was filled from group
Default message: `Prosz臋 wype艂ni膰 przynajmniej ${min} p贸l z grupy.`
Import file: `validatorRequireFromGroup`
Parameters: amount of fields from group, fields identifier
Street
Checks if value is correct street name
Class: `js-validation-street`
Default message: `Wprowad藕 poprawnie nazw臋 ulicy.`
Import file: `validatorStreet`
URL
Overrider url validator message
Default message: `Wprowad藕 poprawny link.`
Import file: `validatorURL`
About Authors
We are a Software House from Europe, headquartered in Poland and employing about 150 people. Our core competencies are built around Magento, Pimcore and bespoke software projects (we love Symfony3, Node.js, Angular, React, Vue.js). We specialize in sophisticated integration projects trying to connect hardcore IT with good product design and UX.
Visit our website Divante.co for more information.