日期:2014-05-16 浏览次数:20374 次
<script>
function count(v){
var cn=(v.match(/[a-z]+
------解决方案--------------------
[\u4E00-\uFA29]/ig)
------解决方案--------------------
[]).length;
document.getElementById('d').innerHTML=cn;
}
</script>
<input type="text" onkeyup="count(this.value)"/>
<div id="d"></div>
<script>
function count(v){
var n = 0;
if(/^[\u4E00-\uFA29]+$/.test(v)) n = v.length;
else if(/^[^\u4E00-\uFA29]+$/.test(v)) n = v.replace(/^
------解决方案--------------------
$
------解决方案--------------------
\S/g, '').length + 1;
document.getElementById('view').innerHTML = n;
}
</script>
<input type="text" onkeyup="count(this.value)"/>
<div id="view"></div>