2006/04/20 | 字符过滤
类别(网摘) | 评论(0) | 阅读(19) | 发表于 03: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

0

评论Comments

日志分类
首页[28]
flash[3]
javascript[3]
C#[1]
feeling[5]
网摘[16]