@vks-dev/jquery-validation-engine
Version:
jQuery Validation Engine 2.6.2 - Form validation engine with custom regex rules - VKS package
177 lines (175 loc) • 8.04 kB
JavaScript
(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": "* Ovo polje je obavezno",
"alertTextCheckboxMultiple": "* Molimo odaberite opciju",
"alertTextCheckboxe": "* Ovaj odabir je obavezan",
"alertTextDateRange": "* Oba datuma su obavezna"
},
"requiredInFunction": {
"func": function(field, rules, i, options){
return (field.val() == "test") ? true : false;
},
"alertText": "* Field must equal test"
},
"dateRange": {
"regex": "none",
"alertText": "* Greška ",
"alertText2": "Raspon datuma"
},
"dateTimeRange": {
"regex": "none",
"alertText": "* Greška ",
"alertText2": "Raspon vremena i datuma"
},
"minSize": {
"regex": "none",
"alertText": "* Minimalno ",
"alertText2": " dozvoljenih znakova"
},
"maxSize": {
"regex": "none",
"alertText": "* Maksimalno ",
"alertText2": " dozvoljenih znakova"
},
"groupRequired": {
"regex": "none",
"alertText": "* Morate popuniti jedno od obaveznih polja"
},
"min": {
"regex": "none",
"alertText": "* Minimalna vrijednost je "
},
"max": {
"regex": "none",
"alertText": "* Maksimalna vrijednost je "
},
"past": {
"regex": "none",
"alertText": "* Datum raniji od "
},
"future": {
"regex": "none",
"alertText": "* Datum nakon "
},
"maxCheckbox": {
"regex": "none",
"alertText": "* Maksimalno ",
"alertText2": " dozvoljenih opcija"
},
"minCheckbox": {
"regex": "none",
"alertText": "* Molimo odaberite ",
"alertText2": " opcija"
},
"equals": {
"regex": "none",
"alertText": "* Polja se ne podudaraju"
},
"creditCard": {
"regex": "none",
"alertText": "* Neispravan broj kreditne kartice"
},
"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": "* Pogrešan unos telefonskog broja"
},
"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": "* Neispravna email adresa"
},
"integer": {
"regex": /^[\-\+]?\d+$/,
"alertText": "* Neispravno unesen broj"
},
"number": {
// Number, including positive, negative, and floating decimal. credit: orefalo
"regex": /^[\-\+]?(([0-9]+)([\.,]([0-9]+))?|([\.,]([0-9]+))?)$/,
"alertText": "* Neispravan broj sa pomičnim zarezom"
},
"date": {
"regex": /^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$/,
"alertText": "* Neispravan unos datuma, ispravan format je GGGG-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": "* neispravna IP adresa"
},
"url": {
"regex": /^(https?|ftp):\/\/[^\s<>]+\.[^\s<>]+$/i,
"alertText": "* Neispravan URL"
},
"onlyNumberSp": {
"regex": /^[0-9\ ]+$/,
"alertText": "* Dozvoljeni su samo brojevi"
},
"onlyLetterSp": {
"regex": /^[a-zA-Z\ \']+$/,
"alertText": "* Dozvoljena su samo slova"
},
"onlyLetterNumber": {
"regex": /^[0-9a-zA-Z]+$/,
"alertText": "* Nisu dozvoljeni specijalni znakovi"
},
// --- 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": "* This user is already taken",
"alertTextLoad": "* Validating, please wait"
},
"ajaxUserCallPhp": {
"url": "phpajax/ajaxValidateFieldUser.php",
// you may want to pass extra data on the ajax call
"extraData": "name=eric",
// if you provide an "alertTextOk", it will show as a green prompt when the field validates
"alertTextOk": "* This username is available",
"alertText": "* This user is already taken",
"alertTextLoad": "* Validating, please wait"
},
"ajaxNameCall": {
// remote json service location
"url": "ajaxValidateFieldName",
// error
"alertText": "* This name is already taken",
// if you provide an "alertTextOk", it will show as a green prompt when the field validates
"alertTextOk": "* This name is available",
// speaks by itself
"alertTextLoad": "* Validating, please wait"
},
"ajaxNameCallPhp": {
// remote json service location
"url": "phpajax/ajaxValidateFieldName.php",
// error
"alertText": "* This name is already taken",
// speaks by itself
"alertTextLoad": "* Validating, please wait"
},
"validate2fields": {
"alertText": "* Please input HELLO"
},
//tls warning:homegrown not fielded
"dateFormat":{
"regex": /^\d{4}-(0[1-9]|1[012])-(0[1-9]|[12]\d|3[01])$/,
"alertText": "* Neispravan datum"
},
//tls warning:homegrown not fielded
"dateTimeFormat": {
"regex": /^\d{4}-(0[1-9]|1[012])-(0[1-9]|[12]\d|3[01]) ([01]\d|2[0-3]):[0-5]\d:[0-5]\d$/,
"alertText": "* Neispravan format datuma",
"alertText2": "Očekivani format: ",
"alertText3": "gggg-mm-dd hh:mm:ss "
}
};
}
};
$.validationEngineLanguage.newLang();
})(jQuery);