I am relatively new to JavaScript, but I will attempt to explain what I am trying to achieve.
Imagine there is an input field where users can add arrays like this:
[users can type any ID, for example: 12345] [button]
purchase IDs: [ ]
However, the current purchase IDs consist of only these 4 arrays.
Purchase IDs: [24149, 24223, 24251, 24253]
Desired Outcome: When the user clicks the button, a check should be performed to confirm if the input ID matches any of the existing purchase IDs. If no match is found, an error message should be displayed to the user.
Question: So, my question is how can I implement a checking method to verify if the user input matches any of the existing purchase IDs?
HTML:
<input type="text" name="test" v-model="text" placeholder="type here"/><v-btn @click="tick()"small color="rgba(10,0,0,0)">click</v-btn><br>
Scripts:
data(){
return{
selected: [],
text:''
}
},
methods:{
tick(){
var array = this.text.split(" ");
array.forEach((item, index)=>{
this.selected.push(parseInt(item))
})
this.text = '';
},
}