I have a field that I want to restrict allowed character input (keypress and copy/paste).
I only want numbers 0-9 and letters A-F (hex). Other characters will not be allowed to be keyed/pasted.
I currently have something like this:
<div v-for="(val, index) in obj">
<q-input outlined v-model="obj[index]" label="Labels" @input="checkChars($event, obj[index])"/>
</div>
Please note that this will be inside a loop and obj[index] is dynamic. Again, I am passing variable of type 'string', not an object (so cant make use of mutability).
Example if I will key in 12kja, I will only want it to allow 12a
Then this is my javascript code:
checkChars (eventValue, param) {
var newVal = eventValue.replace(/[^a-fA-F 0-9\n\r]+/g, '')
console.log('newVal = ' + newVal) // so this prints out 12a correctly
param = newVal // update the parameter with new value
console.log('obj[val1] = ' + this.obj['val1']) // however, this still prints out 12kja
}
How can I make it so that the obj[index] is actually updated and reflect reactively on the q-input text box? Or is there a way to pass obj[index] as a reference?