Tuesday, 15 March 2011

javascript - find mismatch character in the string with regular expression -


I have to find any special characters in addition to the keyboard characters in text area and paste text / text to text, below I What am I trying to do! Please help me as soon as possible?

  if ($ (txtMessage) .val () .tim ()! = "") {Var pattern = "^ [a-zA-Z0-! 9 ~` @ # $% ^ & Amp; * () _ + - = {} |:.? & Lt;>, \ / '] + $ "; (Var i = 0; i & lt; $ (txtMessage) .val () Length; i ++) {var subStr = $ (txtMessage) .val (). Substring (0, i); If ($ SubStr.match (pattern)) {$ ('# customDailogBox') .text ("You have entered or pasted" + subStr.substring (i, i) + "Input characters are not supported characters !!! .. "); }}  

Change the function of your loop status and subparents

 (Var i = 1; i = & lt; $ (txtMessage) .val () Length; i ++) {var subStr = $ (txtMessage) .val (). Substr (i, 1); If (! SubStr.match (pattern)) {$ ('# customDailogBox') Text ("You have entered or pasted" + subStr.substring (i, i) + "Input characters are not supported characters !!! .."); }}  

or you can use regular expression to match mail

  var unmatched_characters = $ (txtMessage) .val () mail Are there. (/[^a-zA-Z0-9~`!@#$%^&*()_+-={}|:;<>,.?\/']/g); If (mismatched _actors.eng> gt; {$ ('# customDailogBox') Text ("You have entered or pasted some characters that are not supported !!! .."); }  

No comments:

Post a Comment