2
I have the following code: http://jsfiddle.net/ntywf/1987/
$(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 "-" signal. But always afterwards I can’t walk with the strokes to the left side, since the function keeps 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?
thanks <3 @Cesarmiguel
– pc_oc
does not detect Ctrl+v or click and drag.. (believe me, there are people who click on a page and drag to another page’s input.. I do this) The safest way is to check the whole value of the input and pass a filter every time there is a focus on the input and to ensure more security, at the time of Submit do the check again.
– Daniel Omine
Yes, that’s also true. I’ll change :P
– CesarMiguel