diff options
| author | Zog | 2018-04-13 14:48:21 +0200 |
|---|---|---|
| committer | cedricnjanga | 2018-04-16 06:43:21 -0700 |
| commit | cdd19438366641ef5069929982030c10018ec00f (patch) | |
| tree | e705d86ecb4a8623a49904104a918d114f3cfcf4 /app/assets/javascripts | |
| parent | ac508f15b191a28a6582a8acb4d177fd20b9baa2 (diff) | |
| download | chouette-core-cdd19438366641ef5069929982030c10018ec00f.tar.bz2 | |
Refs #6337; Make date validation JS locale-agnostic
Diffstat (limited to 'app/assets/javascripts')
| -rw-r--r-- | app/assets/javascripts/smart_date.coffee | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/app/assets/javascripts/smart_date.coffee b/app/assets/javascripts/smart_date.coffee index 48aa1c2f9..9c8b44207 100644 --- a/app/assets/javascripts/smart_date.coffee +++ b/app/assets/javascripts/smart_date.coffee @@ -14,11 +14,16 @@ window.isLeapYear = (year) -> window.smartCorrectDate = -> allSelectors = $(@).parent().children('select') - allVals = allSelectors.map (index, sel) -> - parseInt($(sel).val()) + + yearSelect = allSelectors.filter("[name$='(1i)]']") + monthSelect = allSelectors.filter("[name$='(2i)]']") + daySelect = allSelectors.filter("[name$='(3i)]']") + # We expect [day, month, year], so french + allVals = [daySelect, monthSelect, yearSelect].map (sel, index) -> + parseInt(sel.val()) + correctedDay = correctDay allVals - daySelector = allSelectors.first() - $(daySelector).val(correctedDay) + daySelect.val(correctedDay) $ -> $(document).on 'change', '.smart_date select', smartCorrectDate |
