I have the following code: link
$(document).ready(function () {
$('input').keyup(function() {
var $th = $(this).val();
$th = $th.replace(/[-]/g, "");
$(this).val($th)
console.log( $(this).val());
});
});
What I'm doing is removing the "-" sign. But always after I can not walk with the strokes to the left side, since the function is always sending the cursor to the end of the characters. How can I validate this without the cursor being sent to the end of the input?