1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Help

Discussion in 'JavaScript' started by zurc, Mar 2, 2007.

  1. #1
    Hi I have a textbox then if a user inputs a string on the box then it detects special characters it change them to something else.... does anybody have a script for that
     
    zurc, Mar 2, 2007 IP
  2. Aragorn

    Aragorn Peon

    Messages:
    1,491
    Likes Received:
    72
    Best Answers:
    1
    Trophy Points:
    0
    #2
    Use the following function to replace the characters.
    Populate the arrays arReplace and arReplaceWith with the required characters.
    
    var arReplace = new Array('a', 'b', 'c', 'd', 'e');
    var arReplaceWith = new Array('A', 'B', 'C', 'D', 'E');
    function replace(str){
    	len = arReplace.length;
    	for(i = 0; i < len; i++){
    		str = eval('str.replace(/' + arReplace[i] + '/g,  arReplaceWith[i] )');
    	}
    	return str;
    }
    
    Code (markup):
     
    Aragorn, Mar 2, 2007 IP