字符过滤

      网摘 2006-4-20 3:47
摘自:http://www.darronschall.com/weblog/archives/000077.cfm
search_btn.onRelease = function() {
 	var filtered = ""; // save the filtered string
 	var current = ""; // current character in keyword
 	
 	// loop over the keyword text string
 	for (var i = 0; i < keywords_txt.text.length; i++) {
  		// only allow 0-9, a-z, A-Z and space..
  		// filter out everything else 
  		current = keywords_txt.text.charAt(i);
  		if (current >= "a" && current <= "z"
  			|| current >= "A" && current <= "Z"
  			|| current >= "0" && current <= "9"
  			|| current == " ") {
   			// add character to filtered text
   			filtered += current;
   		} 
  	}
 	
 	// display results to output window
 	trace(filtered);
}

As you can see, the revised code look

标签集:TAGS:
回复Comments() 点击Count()

回复Comments

{commentauthor}
{commentauthor}
{commenttime}
{commentnum}
{commentcontent}
作者:
{commentrecontent}