UNPKG

@vks-dev/jquery-validation-engine

Version:

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

137 lines (134 loc) 6.52 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": "* Необходимо заполнить", "alertTextCheckboxMultiple": "* Вы должны выбрать вариант", "alertTextCheckboxe": "* Необходимо отметить" }, "requiredInFunction": { "func": function(field, rules, i, options){ return (field.val() == "test") ? true : false; }, "alertText": "* Field must equal test" }, "minSize": { "regex": "none", "alertText": "* Минимум ", "alertText2": " символа(ов)" }, "maxSize": { "regex": "none", "alertText": "* Максимум ", "alertText2": " символа(ов)" }, "groupRequired": { "regex": "none", "alertText": "* You must fill one of the following fields" }, "min": { "regex": "none", "alertText": "* Минимальное значение " }, "max": { "regex": "none", "alertText": "* Максимальное значение " }, "past": { "regex": "none", "alertText": "* Дата до " }, "future": { "regex": "none", "alertText": "* Дата от " }, "maxCheckbox": { "regex": "none", "alertText": "* Нельзя выбрать столько вариантов" }, "minCheckbox": { "regex": "none", "alertText": "* Пожалуйста, выберите ", "alertText2": " опцию(ии)" }, "equals": { "regex": "none", "alertText": "* Поля не совпадают" }, "creditCard": { "regex": "none", "alertText": "* Неверный номер кредитной карты" }, "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": "* Неправильный формат телефона" }, "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": "* Неверный формат email" }, "integer": { "regex": /^[\-\+]?\d+$/, "alertText": "* Не целое число" }, "number": { // Number, including positive, negative, and floating decimal. credit: orefalo "regex": /^[\-\+]?(([0-9]+)([\.,]([0-9]+))?|([\.,]([0-9]+))?)$/, "alertText": "* Неправильное число с плавающей точкой" }, "date": { "regex": /^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$/, "alertText": "* Неправильная дата (должно быть в ДД.MM.ГГГГ формате)" }, "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": "* Неправильный IP-адрес" }, "url": { "regex": /^(https?|ftp):\/\/[^\s<>]+\.[^\s<>]+$/i, "alertText": "* Неправильный URL" }, "onlyNumberSp": { "regex": /^[0-9\ ]+$/, "alertText": "* Только числа" }, "onlyLetterSp": { "regex": /^[a-zA-Z\u0400-\u04FF\ \']+$/, "alertText": "* Только буквы" }, "onlyLetterNumber": { "regex": /^[0-9a-zA-Z\u0400-\u04FF]+$/, "alertText": "* Запрещены специальные символы" }, // --- 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": "* Этот пользователь уже занят", "alertTextLoad": "* Проверка, подождите..." }, "ajaxNameCall": { // remote json service location "url": "ajaxValidateFieldName", // error "alertText": "* Это имя уже занято", // if you provide an "alertTextOk", it will show as a green prompt when the field validates "alertTextOk": "* Это имя доступно", // speaks by itself "alertTextLoad": "* Проверка, подождите..." }, "validate2fields": { "alertText": "* Пожалуйста, введите HELLO" } }; } }; $.validationEngineLanguage.newLang(); })(jQuery);