how to remove last character from tvalue? for example: the value was for tvalue = "001 212 777 3456"
now, when the keyboard is called ("BACKSPACE"), it should not be completely cleared, but only delete one character at the end, and not the whole.
function keyboard(input) {
if (input==='BACKSPACE') {
tvalue = '';
} else if(input ==='QUOTE') {
tvalue = tvalue + "'";
} else if(input ==='SPACE') {
tvalue = tvalue + " ";
} else {
tvalue = tvalue + input;
}
$('#' + tinput).val(tvalue).trigger('input');
console.log(">>> Keyboard: ", input);
}
keyboard('BACKSPACE');
console.log('Show me the input now? ' , tvalue);
Expected Result:
001 212 777 345
001 212 777 34
001 212 777 3
001 212 777
001 212 777
001 212 77
Expected result: "Not empty, but only the last character."
source
share