diff --git a/src/lang/ar.js b/src/lang/ar.js index f2165d6..bc88ea8 100644 --- a/src/lang/ar.js +++ b/src/lang/ar.js @@ -24,6 +24,8 @@ badTelephone: 'رقم الهاتف المدخل خاطئ', badSecurityAnswer: 'لم يتم الإجابة عن سؤال الأمان', badDate: 'تاريخ مدخل خاطئ', + badDateBefore: 'The minimum allowed date is ', + badDateAfter: 'The maximum allowed date is ', lengthBadStart: 'القيمة المدخلة يجب أن تكون بين ', lengthBadEnd: ' حروف', lengthTooLongStart: 'القيمة المدخل أطول من ', diff --git a/src/lang/ca.js b/src/lang/ca.js index 3f7123c..4d123d4 100644 --- a/src/lang/ca.js +++ b/src/lang/ca.js @@ -24,6 +24,8 @@ badTelephone: 'El número de telèfon proporcionat no és vàlid', badSecurityAnswer: 'La resposta a la seva pregunta de seguretat és incorrecte', badDate: 'La data proporcionada no és vàlida', + badDateBefore: 'The minimum allowed date is ', + badDateAfter: 'The maximum allowed date is ', lengthBadStart: 'La seva resposta s\'ha d\'incloure entre ', lengthBadEnd: ' caràcters', lengthTooLongStart: 'La seva resposta ha de ser menor a ', diff --git a/src/lang/cs.js b/src/lang/cs.js index b2a5bd8..2c89dd6 100644 --- a/src/lang/cs.js +++ b/src/lang/cs.js @@ -24,6 +24,8 @@ badTelephone: 'Neplatné telefonní číslo', badSecurityAnswer: 'Chybná odpověď na bezpečnostní otázku', badDate: 'Nesprávné datum', + badDateBefore: 'The minimum allowed date is ', + badDateAfter: 'The maximum allowed date is ', lengthBadStart: 'Zadaná hodnota musí být v rozmezí ', lengthBadEnd: ' znaků', lengthTooLongStart: 'Zadaná hodnota je větší než ', diff --git a/src/lang/da.js b/src/lang/da.js index fe875bc..277b9aa 100644 --- a/src/lang/da.js +++ b/src/lang/da.js @@ -23,6 +23,8 @@ badCreditCard:'Det angivne kortnummer er ugyldigt', badCustomVal: 'Den indtastede værdi er ugyldig', badDate: 'Den angivne dato er ugyldig', + badDateBefore: 'The minimum allowed date is ', + badDateAfter: 'The maximum allowed date is ', badDomain: 'Det angivne domæne er ugyldigt', badEmail: 'Den angivne email adresse er ugyldig', badInt: 'Det angivne tal er ugyldigt', diff --git a/src/lang/de.js b/src/lang/de.js index 485f92d..42651ac 100644 --- a/src/lang/de.js +++ b/src/lang/de.js @@ -24,6 +24,8 @@ badTelephone: 'Sie haben keine richtige Telefonnummer eingetragen', badSecurityAnswer: 'Sie haben die falsche Antwort auf die Sicherheitsfrage eingegeben', badDate: 'Eingabe eines falschen Datums', + badDateBefore: 'The minimum allowed date is ', + badDateAfter: 'The maximum allowed date is ', lengthBadStart: 'Der eingegebene Wert muss dazwischen sein ', lengthBadEnd: '  Zeichen', lengthTooLongStart: 'Der eingegebene Wert ist größer als ', diff --git a/src/lang/es.js b/src/lang/es.js index 4bf3750..f7d7510 100644 --- a/src/lang/es.js +++ b/src/lang/es.js @@ -24,6 +24,8 @@ badTelephone: 'El número de teléfono proporcionado no es válido', badSecurityAnswer: 'La respuesta a su pregunta de seguridad es incorrecta', badDate: 'La fecha proporcionada no es válida', + badDateBefore: 'The minimum allowed date is ', + badDateAfter: 'The maximum allowed date is ', lengthBadStart: 'Su respuesta debe incluir entre ', lengthBadEnd: ' caracteres', lengthTooLongStart: 'Su respuesta debe de ser menor a ', diff --git a/src/lang/fa.js b/src/lang/fa.js index e163493..6fc37e2 100644 --- a/src/lang/fa.js +++ b/src/lang/fa.js @@ -26,6 +26,8 @@ badTelephone: 'شماره تلفن وارد شده معتبر نیست', badSecurityAnswer: 'شما به سوال امنیتی درست پاسخ نداده اید', badDate: 'تاریخ درستی را وارد نکرده اید', + badDateBefore: 'The minimum allowed date is ', + badDateAfter: 'The maximum allowed date is ', lengthBadStart: 'مقدار وارد شده باید ', lengthBadEnd: ' حرف باشد.', lengthTooLongStart: 'مقدار ورودی بیشتر از ', diff --git a/src/lang/fr.js b/src/lang/fr.js index 2259e7f..06a8154 100644 --- a/src/lang/fr.js +++ b/src/lang/fr.js @@ -24,6 +24,8 @@ badTelephone: 'Vous n\'avez pas saisi un numéro de téléphone valide', badSecurityAnswer: 'Vous avez saisi une mauvaise réponse à la question de sécurité', badDate: 'Vous n\'avez pas saisi une date correcte', + badDateBefore: 'The minimum allowed date is ', + badDateAfter: 'The maximum allowed date is ', lengthBadStart: 'Votre saisie doit comporter entre ', lengthBadEnd: ' caractères', lengthTooLongStart: 'Vous avez saisi une réponse qui est plus longue que ', diff --git a/src/lang/it.js b/src/lang/it.js index 35cf0ba..be6b1dd 100644 --- a/src/lang/it.js +++ b/src/lang/it.js @@ -24,6 +24,8 @@ badTelephone: 'Il numero di telefono imputato non è valido', badSecurityAnswer: 'La risposta alla domanda di sicurezza è errata', badDate: 'La data scelta non è valida', + badDateBefore: 'The minimum allowed date is ', + badDateAfter: 'The maximum allowed date is ', lengthBadStart: 'La sua risposta non può essere più lunga di ', lengthBadEnd: ' caratteri', lengthTooLongStart: 'La lunghezza della risposta deve essere minore di ', diff --git a/src/lang/ka.js b/src/lang/ka.js index eb42c13..964e397 100644 --- a/src/lang/ka.js +++ b/src/lang/ka.js @@ -24,6 +24,8 @@ badTelephone: 'თქვენ მიუთითეთ არასწორი ტელეფონის ნომერი', badSecurityAnswer: 'თქვენ გაეცით არასწორი პასუხი უსაფრთხოების კითხვას', badDate: 'თქვენ მიუთითეთ არასწორი თარიღი', + badDateBefore: 'The minimum allowed date is ', + badDateAfter: 'The maximum allowed date is ', lengthBadStart: 'ველის მნიშვნელობის სიგრძე უნდა იყოს ', lengthBadEnd: ' შუალედში', lengthTooLongStart: 'ველის მნიშვნელობის სიგრძე უნდა იყოს მაქსიმუმ ', diff --git a/src/lang/ko.js b/src/lang/ko.js index 2ed7d38..0359a77 100644 --- a/src/lang/ko.js +++ b/src/lang/ko.js @@ -24,6 +24,8 @@ badTelephone: '전화번호를 정확하게 입력하지 않았습니다.', badSecurityAnswer: '보안 입력을 정확하게 입력하지 않았습니다.', badDate: '날짜를 정확하게 입력하지 않았습니다.', + badDateBefore: 'The minimum allowed date is ', + badDateAfter: 'The maximum allowed date is ', lengthBadStart: '입력 값은 ', lengthBadEnd: ' 사이의 문자여야 합니다.', lengthTooLongStart: '입력 값의 길이가 ', diff --git a/src/lang/nl.js b/src/lang/nl.js index f6df88e..848df45 100644 --- a/src/lang/nl.js +++ b/src/lang/nl.js @@ -23,6 +23,8 @@ badCreditCard: 'Het creditcardnummer is onjuist', badCustomVal: 'De ingevoerde waarde is onjuist', badDate: 'U heeft niet de juiste datum aangegeven', + badDateBefore: 'The minimum allowed date is ', + badDateAfter: 'The maximum allowed date is ', badDomain: 'Incorrect domein', badEmail: 'U heeft een onjuist e-mailadres ingevoerd ', badInt: 'De ingevoerde waarde was een onjuist getal', diff --git a/src/lang/no.js b/src/lang/no.js index 8aca430..bca475f 100644 --- a/src/lang/no.js +++ b/src/lang/no.js @@ -23,6 +23,8 @@ badCreditCard: 'Kredittkortnummeret er ikke korrekt', badCustomVal: 'Inntastingsverdien er ikke korrekt', badDate: 'Du har ikke oppgitt en korrekt dato', + badDateBefore: 'The minimum allowed date is ', + badDateAfter: 'The maximum allowed date is ', badDomain: 'Ukorrekt domeneverdi', badEmail: 'Du har ikke oppgitt en korrekt e-postadresse', badInt: 'Inntastingsverdien er ikke et korrekt tall', diff --git a/src/lang/pl.js b/src/lang/pl.js index 5258b0d..1219813 100644 --- a/src/lang/pl.js +++ b/src/lang/pl.js @@ -24,6 +24,8 @@ badTelephone: 'Wprowadzono niepoprawny numeru telefonu', badSecurityAnswer: 'Nieprawidłowa odpowiedź na pytanie bezpieczeństwa', badDate: 'Niepoprawna data', + badDateBefore: 'The minimum allowed date is ', + badDateAfter: 'The maximum allowed date is ', lengthBadStart: 'Wprowadzona wartość musi być pomiędzy ', lengthBadEnd: ' znaków', lengthTooLongStart: 'Wprowadzona wartość jest większa niż ', diff --git a/src/lang/pt.js b/src/lang/pt.js index d956150..338e200 100644 --- a/src/lang/pt.js +++ b/src/lang/pt.js @@ -24,6 +24,8 @@ badTelephone: 'O telefone digitado não é válido', badSecurityAnswer: 'A pergunta de segurança não foi respondida corretamente', badDate: 'A data digitada não é válida', + badDateBefore: 'A data mínima permitida é ', + badDateAfter: 'A data máxima permitida é ', lengthBadStart: 'Sua resposta deve incluir entre ', lengthBadEnd: ' caracteres', lengthTooLongStart: 'Sua resposta tem mais que ', diff --git a/src/lang/ro.js b/src/lang/ro.js index d223cad..7999cb6 100644 --- a/src/lang/ro.js +++ b/src/lang/ro.js @@ -24,6 +24,8 @@ badTelephone: 'Numărul de telefon este incorect', badSecurityAnswer: 'Răspuns incorect la întrebarea de siguran?ă', badDate: 'Dară incorectă', + badDateBefore: 'The minimum allowed date is ', + badDateAfter: 'The maximum allowed date is ', lengthBadStart: 'Valoarea introdusă trebuie să fie interval ', lengthBadEnd: ' caractere', lengthTooLongStart: 'Valoarea introdusă este mai mare decât ', diff --git a/src/lang/ru.js b/src/lang/ru.js index f281dd2..06de9ce 100644 --- a/src/lang/ru.js +++ b/src/lang/ru.js @@ -25,6 +25,8 @@ badTelephone: 'Вы задали некорректный номер телефона', badSecurityAnswer: 'Вы задали некорректный ответ на секретный вопрос', badDate: 'Вы задали некорректную дату', + badDateBefore: 'The minimum allowed date is ', + badDateAfter: 'The maximum allowed date is ', lengthBadStart: 'Значение должно быть в диапазоне', lengthBadEnd: ' символов', lengthTooLongStart: 'Значение длинее, чем ', diff --git a/src/lang/sv.js b/src/lang/sv.js index 3ce91b3..ec6c9f5 100644 --- a/src/lang/sv.js +++ b/src/lang/sv.js @@ -24,6 +24,8 @@ badTelephone: 'Du har inte angett ett korrekt telefonnummer', badSecurityAnswer: 'Du har angett fel svar på säkerhetsfrågan', badDate: 'Du har anget ett felaktigt datum', + badDateBefore: 'The minimum allowed date is ', + badDateAfter: 'The maximum allowed date is ', lengthBadStart: 'Ditt svar måste innehålla mellan ', lengthBadEnd: ' tecken', lengthTooLongStart: 'Du har angett ett svar som är längre än ', diff --git a/src/lang/tr.js b/src/lang/tr.js index f76d50e..e1513e8 100644 --- a/src/lang/tr.js +++ b/src/lang/tr.js @@ -24,6 +24,8 @@ badTelephone: 'Geçersiz telefon numarası girdiniz', badSecurityAnswer: 'Güvenlik sorusuna doğru cevap vermediniz', badDate: 'Geçersiz tarih girdiniz', + badDateBefore: 'The minimum allowed date is ', + badDateAfter: 'The maximum allowed date is ', lengthBadStart: 'Girilen değer ', lengthBadEnd: ' karakter olmalıdır', lengthTooLongStart: 'Girilen değer en fazla ', diff --git a/src/lang/vi.js b/src/lang/vi.js index 9aa01f5..789901c 100644 --- a/src/lang/vi.js +++ b/src/lang/vi.js @@ -23,6 +23,8 @@ badTelephone: 'Số điện thoại chưa chính xác', badSecurityAnswer: 'Câu hỏi bảo mật chưa chính xác', badDate: 'Ngày tháng chưa chính xác', + badDateBefore: 'The minimum allowed date is ', + badDateAfter: 'The maximum allowed date is ', lengthBadStart: 'Yêu cầu nhập từ ', lengthBadEnd: ' ký tự', lengthTooLongStart: 'Dữ liệu quá dài, yêu cầu ít hơn ', diff --git a/src/main/core-validators.js b/src/main/core-validators.js index 8f2f409..10c22f9 100644 --- a/src/main/core-validators.js +++ b/src/main/core-validators.js @@ -273,16 +273,46 @@ /* * Validate date + * element attrs (optional, and both must use the same format as the field) + * data-validation-min-date + * data-validation-max-date */ $.formUtils.addValidator({ name: 'date', - validatorFunction: function (date, $el, conf) { + validatorFunction: function (date, $el, conf, lang) { var dateFormat = $el.valAttr('format') || conf.dateFormat || 'yyyy-mm-dd', addMissingLeadingZeros = $el.valAttr('require-leading-zero') === 'false'; - return $.formUtils.parseDate(date, dateFormat, addMissingLeadingZeros) !== false; - }, - errorMessage: '', - errorMessageKey: 'badDate' + var dateParsed = $.formUtils.parseDate(date, dateFormat, addMissingLeadingZeros); + //checking date format + if (dateParsed === false){ + this.errorMessage = lang.badDate; + return false; + } + var dateInput = new Date(dateParsed[0], dateParsed[1] - 1, dateParsed[2]); + //checking min date, when informed + var dateMinValue = $el.valAttr('min-date'); + if (dateMinValue !== false && $.formUtils.parseDate(dateMinValue, dateFormat, addMissingLeadingZeros) !== false){ + var dateMinParsed = $.formUtils.parseDate(dateMinValue, dateFormat, addMissingLeadingZeros); + var dateMin = new Date(dateMinParsed[0], dateMinParsed[1] - 1, dateMinParsed[2]); + if (dateInput < dateMin){ + this.errorMessage = lang.badDateBefore + dateMinValue; + return false; + } + } + //checking max date, when informed + var dateMaxValue = $el.valAttr('max-date'); + if (dateMaxValue !== false && $.formUtils.parseDate(dateMaxValue, dateFormat, addMissingLeadingZeros) !== false){ + var dateMaxParsed = $.formUtils.parseDate(dateMaxValue, dateFormat, addMissingLeadingZeros); + var dateMax = new Date(dateMaxParsed[0], dateMaxParsed[1] - 1, dateMaxParsed[2]); + if (dateInput > dateMax){ + this.errorMessage = lang.badDateAfter + dateMaxValue; + return false; + } + } + return true; + } + //errorMessage: '', //setted above on the function + //errorMessageKey: 'badDate' //not used }); diff --git a/src/main/utils.js b/src/main/utils.js index 95b102b..beb2093 100644 --- a/src/main/utils.js +++ b/src/main/utils.js @@ -646,6 +646,8 @@ badTelephone: 'You have not given a correct phone number', badSecurityAnswer: 'You have not given a correct answer to the security question', badDate: 'You have not given a correct date', + badDateBefore: 'The minimum allowed date is ', + badDateAfter: 'The maximum allowed date is ', lengthBadStart: 'The input value must be between ', lengthBadEnd: ' characters', lengthTooLongStart: 'The input value is longer than ',