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