判断全角的逗号,并把全角的逗号转换成半角的逗号?
<P><input type="text" name="ss" value="武汉,北京,上海"/><BR><BR>文本域里如果有全角的逗号则转换为半角的逗号 </P> <P>搞定了。<br></P><DIV class=htmlcode>function fullChar2halfChar(str)<br>{<br> var result = '';<br><br> for (i=0 ; i<str.length; i++)<br> { <br> code = str.charCodeAt(i);//获取当前字符的unicode编码<br> if (code >= 65281 && code <= 65373)//在这个unicode编码范围中的是所有的英文字母已经各种字符<br> {<br> result += String.fromCharCode(str.charCodeAt(i) - 65248);//把全角字符的unicode编码转换为对应半角字符的unicode码<br> }else if (code == 12288)//空格<br> {<br> result += String.fromCharCode(str.charCodeAt(i) - 12288 + 32);<br> }else<br> {<br> result += str.charAt(i);<br> }<br> }<br> return result;<br>}</DIV>
[align=right][color=#000066][此贴子已经被作者于2007-11-17 18:03:24编辑过][/color][/align]
页:
[1]
