javascript - Cant use arrows inside input -
hi did not make script, posting form, simple html,
this html in input
<input class="text_box" type="text" name="title" id="title" size="19" value="title" onkeydown="specialreplace(this)" onkeyup="specialreplace(this)" onblur="specialreplace(this)" onclick="specialreplace(this)"/>
and specialreplace() function
function specialreplace(o) { o.value=o.value.replace(/[^a-za-z0-9 áéíóúÁÉÍÓÚÜüñѨ´,.¿?%&$!¡ªº#"()-_\/]/g,''); }
i try use arrows, go specific letter "edit" cant use arrows in input, why??
and how can solve this?
why these inline handlers if using jquery?
anyway, here's how it:
html
<input class="text_box" type="text" name="title" id="title" size="19" value="title">
js
$(function () { //you have escaped - character in character class var cleanrx = /[^a-za-z0-9 áéíóúÁÉÍÓÚÜüñѨ´,.¿?%&$!¡ªº#"()\-_\/]/g; $('#title').keyup(function (e) { var = e.which; //avoid useless replacements when <- , -> keys pressed if (which === 39 || === 37) return; this.value = this.value.replace(cleanrx, ''); }).trigger('keyup'); //perform replacement on initial content (remove if uneeded) });
Comments
Post a Comment