Skip to content

Commit e4eb0e5

Browse files
committed
Fixing the label for inputs when we received an invalid value
1 parent ff6d041 commit e4eb0e5

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/components/MdField/MdField.vue

+3-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@
6060
password: null,
6161
togglePassword: false,
6262
clear: false,
63-
file: false
63+
file: false,
64+
hasInvalidValue: false
6465
}
6566
}),
6667
provide () {
@@ -79,7 +80,7 @@
7980
return this.mdTogglePassword && this.MdField.password
8081
},
8182
hasValue () {
82-
return this.stringValue && this.stringValue.length > 0
83+
return (this.stringValue && this.stringValue.length > 0) || this.MdField.hasInvalidValue
8384
},
8485
valueLength () {
8586
if (this.stringValue) {

src/components/MdField/MdFieldMixin.js

+4
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export default {
2424
if (value.constructor.toString().match(/function (\w*)/)[1].toLowerCase() !== 'inputevent') {
2525
this.$nextTick(() => {
2626
this.localValue = value
27+
this.MdField.hasInvalidValue = this.isInvalidValue();
2728
})
2829
}
2930
}
@@ -95,6 +96,9 @@ export default {
9596
}
9697
}
9798
},
99+
isInvalidValue () {
100+
return this.$el.validity.badInput
101+
},
98102
setFieldValue () {
99103
this.MdField.value = this.model
100104
},

0 commit comments

Comments
 (0)