Hello guys I have the following code input :
<v-file-input
show-size
accept=".xlsx"
label="File input"
@change="selectFile"
></v-file-input>
How can I make it accept only specific names.xlsx? Like it will accept xlsx files containing specific words in It.
Example:
name-george.xlsx true
name-anna.xlsx false
george-surname.xlsx true
I want It to contain george word inside the xlsx File Name
CodePudding user response:
use a validation rule. Here is an example to get you started
https://codepen.io/radvic/pen/XWYxKpQ
new Vue({
el: '#app',
vuetify: new Vuetify(),
data: () => ({
rules: [
v => {
for(index in v){
const fileName = v[index].name;
if(fileName.match(/george(.*)\.xlsx/g) === null){
return 'The file name "' fileName '" is wrong';
}
}
return true;
},
],
}),
})
<script src="https://cdn.jsdelivr.net/npm/babel-polyfill/dist/polyfill.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vuetify.min.js"></script>
<div id="app">
<v-app id="inspire">
<v-file-input multiple :rules="rules" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"></v-file-input>
</v-app>
</div>