i have textbox, forbidden character cant typed. #.
this works, however, when textbox filled in data, , put focus on middle of textbox , use arrow keys go left , right, jumps end of textbox.
if type character in middle of textbox, goes end again
$('[id$=txtclient]').keyup(function () { enableclientvalidatebutton(); // when textbox changes, user has ability validate client changecolorclient("0"); // color changed white, notify user client not validated yet. var $el = $('[id$=txtclient]'); // text element seach forbidden characters. var text = $el.val(); // value of textbox text = text.split("#").join("");//remove occurances of forbidden characters, in case # $el.val(text);//set on element });
this bit unpleasant, , i'm not 100% happy, solves given issues you've had...
$("[id$=txtclient]").keyup(function (e) { var text = $(this).val(); if (text.indexof("#") > -1) { text = text.replace("#", ""); $(this).val(text); } });
here's jsfiddle example...
Comments
Post a Comment