79283280

Date: 2024-12-15 22:31:14
Score: 0.5
Natty:
Report link

A simple way to get it working is to get the character before the carret with selectionStart:

input.value[input.selectionStart-1];

Adapting your code:

<input id="myInput" type='text' oninput="validate(this)" />

function validate(input) {
    console.log(input.value[input.selectionStart - 1]);
}
Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Rusca8