date picker and timer picker in one input text
Date : March 29 2020, 07:55 AM
seems to work fine I don't see time picker in your code. FYI: default jQuery date picker doesn't allow time picker, for that you need another plugin along with jQuery.
|
Vuetify: How to fix v-date-picker not showing the chosen date in the text-field
Tag : date , By : user87752
Date : March 29 2020, 07:55 AM
I wish did fix the issue. I'm creating a form with vue.js / vuetify 2, one of the field is Date Event, so I used v-date-picker for the user to choose the date. The problems are the following: , Try this: <template>
<v-menu
v-model="showPicker"
:close-on-content-click="false"
transition="scale-transition"
offset-y
full-width
max-width="290px"
min-width="290px"
>
<template v-slot:activator="{ on }">
<v-text-field
v-model="selectedDate"
label="Choose the date"
hint="YYYY/MM/DD"
persistent-hint
readonly
v-on="on"
></v-text-field>
</template>
<v-date-picker
v-model="selectedDate"
no-title
@input="showPicker = false"
></v-date-picker>
</v-menu>
</template>
<script>
export default {
data: () => ({
showPicker: false,
selectedDate: null,
})
</script>
|
How to input date and time in a Vuetify text input field
Date : March 29 2020, 07:55 AM
|
Custom date picker in Vuetify
Date : March 29 2020, 07:55 AM
Any of those help Changes i've made to get it to work, is that i've added a computed with a get() and set(). The getter will return the current selected value, and the setter will be emitting the new value each time it's changing. This is a good way of utilizing the v-model within custom components. <template>
<v-container fill-height>
<v-row justify="center" align="center">
<v-col cols="12">
<!-- Date picker -->
<v-menu
ref="menu1"
v-model="menu1"
:close-on-content-click="false"
transition="scale-transition"
offset-y
>
<template v-slot:activator="{ on }">
<v-text-field
v-model="selected"
v-on:input="$emit('input', $event)"
@blur="date = parseDate(value)"
v-on="on"
value
label="Date"
color="green lighten-1"
/>
</template>
<v-date-picker
v-model="selected"
@input="menu1 = false"
no-title
header-color="green lighten-1"
color="green lighten-1"
/>
</v-menu>
<!-- end of date picker -->
</v-col>
</v-row>
</v-container>
</template>
<script>
export default {
name: 'CustomDatePicker',
props: {
value: {
type: String,
default: ''
}
},
data () {
return {
menu1: null,
date: null
}
},
computed: {
selected: {
get() {
return this.value
},
set(value) {
this.$emit('input', value)
}
},
computedDateFormatted () {
return this.formatDate(this.date)
}
},
watch: {
date (val) {
this.value = this.formatDate(this.date)
}
},
methods: {
formatDate (date) {
if (!date) { return null }
return date
},
parseDate (date) {
if (!date) { return null }
const [year, month, day] = date.split('-')
return `${year}-${month.padStart(2, '0')}-${day.padStart(2, '0')}`
}
}
}
</script>
|
Make Vuetify v-text-field component required by default
Tag : vue.js , By : algoRhythm99
Date : March 29 2020, 07:55 AM
hop of those help? You could do the following: Create a v-form and place your textfields inside the form. Don't forget to give your v-form a v-model and a ref too. <v-form v-model="formValid" ref="myForm">
<v-text-field label="Field 1" :rules="rules.required"></v-text-field>
<v-text-field label="Field 2" :rules="rules.required"></v-text-field>
</v-form>
<script>
export default {
data() {
return {
formValid: false,
rules: {
required: [value => !!value || "Required."]
}
};
},
mounted() {
this.$refs.myForm.validate();
}
};
</script>
|