javascript - Removing unwanted characters from textbox with JQuery -


How would I want to get some input, is that how to type some characters from the text box (or Textera) with JQuery I have code in C #, but I am unable to translate it into javascript javascript. My problem is that I do not know how to get the value from a text box as a character array which I can do again through the loop and compare it against a given unwanted characters. By the way, "away" I came to JQuery:

  $ ("input [type = text], textarea"). Change (function () {// code here});  

This is my code for C #:

  (int i = 0; i & lt; charArray.Length; i ++) {current = CharArray [i]; If ((current == 0x 9) || (current == 0xA) || (current == 0xD) || ((current> gt = = 0x20) & amp; amp; amp; amp; amp; (current & Lt; = 0xD7FF)) || ((current> gt; = 0xE000) & amp; amp; amp; amp; current (& lt; = 0xFFFD)) _validXML.Append (current); } Back _validXML.ToString (). TrimEnd ((four) 32, (four) 160);  Update:   

I went with a combination of the following answers (I will remove them) and my last JQuery looks like this and works: < / P>

  $ (document) .ready (function () {$ (": text, textarea"). Changes (function () {var text = "var arr = $ (this) .val () $ .each (AR, function (i) {var c = arr.charCodeAt (i); if ((C == 0x9) || (C == 0xA) || (C == 0xD) || ( C & gt; = 0x20 & c & lt; = 0xD7FF) ((C & gt; = 0xE000 & amp; lift; = 0xFFFD)) {text + = arr.charAt (i);} }); $ (This) .val (text);});});  

All thanks!

text:

  & lt; Textarea id = "item" name = "item" rows = "5" cols = "80" & gt; Here's some text & lt; / Textarea & gt;  

jQuery code:

  var text = $ ('# item'). Val (); Var newtext = ""; (Var i = 0; i & lt; text.length; i ++) for {var c = text.charCodeAt (i); If ((C == 0x9) || (C == 0xA) || (C == 0xD) || (C & gt; = 0x20 & c & lt; = 0xD7FF) || (C & gt; = 0xE000 & amp; amp; amp; amp;; = 0xFFFD)) {newtext + = c; }} $ ('# Items'). Val (new text);  

This is actually very small, except for JPL, Methinks, except for accessing the text data and resetting it.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

Visual Studio 2005: How to speed up builds when a VSMDI is open? -

booting ubuntu from usb using virtualbox -