Friday, May 10, 2024
 Popular · Latest · Hot · Upcoming
65
rated 0 times [  71] [ 6]  / answers: 1 / hits: 18366  / 4 Years ago, thu, february 20, 2020, 12:00:00

I try to implement a maxLength for an input from bootstrap-vue, but from what I read from their documentation they don't support max. If I remove type=number, it works , but is not a number anymore.



    <b-form-input
size=sm
v-model=register_volume_first
type=number
maxlength=4
placeholder=1902
></b-form-input>

More From » vue.js

 Answers
21

Try to use formatter prop as follows:


<template>
<div>
<b-form-input size="sm" v-model="volume" type="number" :formatter="formatYear" placeholder="1902"></b-form-input>
<div class="mt-2">Value: {{ volume }}</div>
</div>
</template>

<script>
export default {
data() {
return {
volume: '4'
}
},
methods:{
formatYear(e){
return String(e).substring(0,4);
}
}
}
</script>

[#51187] Thursday, February 13, 2020, 4 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
samaraanandah

Total Points: 94
Total Questions: 86
Total Answers: 99

Location: Montenegro
Member since Thu, Jun 16, 2022
2 Years ago
;