Validate year based on min and max dates and only show the validation icons when the date has been completely filled in
This commit is contained in:
parent
843501c00a
commit
32583feb99
@ -102,7 +102,9 @@ export default {
|
|||||||
|
|
||||||
isYearValid: function() {
|
isYearValid: function() {
|
||||||
// Emit a change event
|
// Emit a change event
|
||||||
var valid = parseInt(this.year) >= 1
|
var minYear = new Date(this.mindate).getFullYear()
|
||||||
|
var maxYear = new Date(this.maxdate).getFullYear()
|
||||||
|
var valid = this.year >= minYear && this.year <= maxYear
|
||||||
this._emitChange('year', this.year, valid)
|
this._emitChange('year', this.year, valid)
|
||||||
return valid
|
return valid
|
||||||
},
|
},
|
||||||
@ -135,6 +137,15 @@ export default {
|
|||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
isDateComplete: function() {
|
||||||
|
return (
|
||||||
|
!!this.day &&
|
||||||
|
!!this.month &&
|
||||||
|
!!this.year &&
|
||||||
|
this.year > 999
|
||||||
|
)
|
||||||
|
},
|
||||||
|
|
||||||
daysMaxCalculation: function() {
|
daysMaxCalculation: function() {
|
||||||
switch (parseInt(this.month)) {
|
switch (parseInt(this.month)) {
|
||||||
case 2: // February
|
case 2: // February
|
||||||
@ -161,7 +172,7 @@ export default {
|
|||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
onInput: function(e) {
|
onInput: function(e) {
|
||||||
this.showValidation = true
|
if (this.isDateComplete) this.showValidation = true
|
||||||
|
|
||||||
emitEvent('field-change', this, {
|
emitEvent('field-change', this, {
|
||||||
value: this.formattedDate,
|
value: this.formattedDate,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user