UNPKG

@vks-dev/jquery-validation-engine

Version:

jQuery Validation Engine 2.6.2 - Form validation engine with custom regex rules - VKS package

141 lines (139 loc) 6.36 kB
(function($){ $.fn.validationEngineLanguage = function(){ }; $.validationEngineLanguage = { newLang: function(){ $.validationEngineLanguage.allRules = { "required": { // Add your regex rules here, you can take telephone as an example "regex": "none", "alertText": "* Pole wymagane", "alertTextCheckboxMultiple": "* Proszę wybrać opcję", "alertTextCheckboxe": "* Pole wymagane" }, "requiredInFunction": { "func": function(field, rules, i, options){ return (field.val() == "test") ? true : false; }, "alertText": "* Field must equal test" }, "minSize": { "regex": "none", "alertText": "* Minimalna liczba znaków to ", "alertText2": "" }, "maxSize": { "regex": "none", "alertText": "* Maksymalna liczba znaków to ", "alertText2": "" }, "groupRequired": { "regex": "none", "alertText": "* You must fill one of the following fields" }, "min": { "regex": "none", "alertText": "* Najmniejsza wartość to " }, "max": { "regex": "none", "alertText": "* Największa wartość to " }, "past": { "regex": "none", "alertText": "* Data musi być wcześniejsza niż " }, "future": { "regex": "none", "alertText": "* Data musi być późniejsza niż " }, "maxCheckbox": { "regex": "none", "alertText": "* Przekroczona maksymalna liczba opcji" }, "minCheckbox": { "regex": "none", "alertText": "* Minimalna liczba opcji to ", "alertText2": "" }, "equals": { "regex": "none", "alertText": "* Pola nie są jednakowe" }, "creditCard": { "regex": "none", "alertText": "* Nieprawidłowy numer karty kredytowej" }, "phone": { // credit: jquery.h5validate.js / orefalo "regex": /^([\+][0-9]{1,3}[ \.\-])?([\(]{1}[0-9]{2,6}[\)])?([0-9 \.\-\/]{3,20})((x|ext|extension)[ ]?[0-9]{1,4})?$/, "alertText": "* Nieprawidłowy numer telefonu" }, "email": { // Shamelessly lifted from Scott Gonzalez via the Bassistance Validation plugin http://projects.scottsplayground.com/email_address_validation/ "regex": /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)+$/, "alertText": "* Nieprawidłowy adres e-mail" }, "integer": { "regex": /^[\-\+]?\d+$/, "alertText": "* Nieprawidłowa liczba całkowita" }, "number": { // Number, including positive, negative, and floating decimal. credit: orefalo "regex": /^[\-\+]?(([0-9]+)([\.,]([0-9]+))?|([\.,]([0-9]+))?)$/, "alertText": "* Nieprawidłowa liczba dziesiętna" }, "CZdate": { // Date in Polish format, regex taken from Czech translation "regex": /^(0[1-9]|[12][0-9]|3[01])[. /.](0[1-9]|1[012])[. /.](19|20)\d{2}$/, "alertText": "* Data musi być w postaci DD.MM.RRRR" }, "date": { "regex": /^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$/, "alertText": "* Data musi być w postaci RRRR-MM-DD" }, "ipv4": { "regex": /^((([01]?[0-9]{1,2})|(2[0-4][0-9])|(25[0-5]))[.]){3}(([0-1]?[0-9]{1,2})|(2[0-4][0-9])|(25[0-5]))$/, "alertText": "* Nieprawidłowy adres IP" }, "url": { "regex": /^(https?|ftp):\/\/[^\s<>]+\.[^\s<>]+$/i, "alertText": "* Nieprawidłowy adres internetowy" }, "onlyNumberSp": { "regex": /^[0-9\ ]+$/, "alertText": "* Tylko liczby" }, "onlyLetterSp": { "regex": /^[a-zA-Z\ \']+$/, "alertText": "* Tylko litery" }, "onlyLetterNumber": { "regex": /^[0-9a-zA-Z]+$/, "alertText": "* Tylko litery i liczby" }, // --- CUSTOM RULES -- Those are specific to the demos, they can be removed or changed to your likings "ajaxUserCall": { "url": "ajaxValidateFieldUser", // you may want to pass extra data on the ajax call "extraData": "name=eric", "alertText": "* Nazwa użytkownika jest już zajęta", "alertTextLoad": "* Walidacja, proszę czekać" }, "ajaxNameCall": { // remote json service location "url": "ajaxValidateFieldName", // error "alertText": "* Nazwa jest już zajęta", // if you provide an "alertTextOk", it will show as a green prompt when the field validates "alertTextOk": "* Nazwa jest dostępna", // speaks by itself "alertTextLoad": "* Walidacja, proszę czekać" }, "validate2fields": { "alertText": "* Proszę wpisać HELLO" } }; } }; $.validationEngineLanguage.newLang(); })(jQuery);