0
在我的项目中我有任务给用户输入的字符进行计数并显示计数它工作正常,但我想添加只允许特殊字符的正则表达式如何计算字符串中的特殊字符javascript函数只接受像@#
<!DOCTYPE html>
<script type="text/javascript">
function countChars(countfrom,displayto)
{
var len = document.getElementById(countfrom).value.length;
document.getElementById(displayto).innerHTML = len;
}
</script>
<label>Enter Character</label><br>
<textarea id="data" cols="40" rows="5"
onkeyup="countChars('data','charcount');" onkeydown="countChars('data','charcount');"
onmouseout="countChars('data','charcount');">
</textarea><br>
<span id="charcount">0</span>
</html>
你可以使用 – Araz
没有你能解释JavaScript的资产匹配我请 – sms
看到此链接:http://www.w3schools.com/jsref/jsref_match.asp – Araz