我需要开发一个javascript函数,不允许字符串中出现特殊字符(\xc2\xae \xc2\xb4 \xc2\xa9 \xc2\xbf \xc2\xa1 \xc2\xb0 \xc3\x80 )。问题是IE8无法识别字符串中的特殊字符,并且在使用indexOf()方法时返回-1。处理这些特殊字符的正确方法是什么?
\n我document.my_formm.fieldName.value is null or not an object从下面的代码中得到一个错误():
<html>
<head>
<title>(Type a title for your page here)</title>
<script language=JavaScript>
function check_length(my_formm,fieldName)
{
alert(fieldName);
alert(document.my_formm.fieldName.value);
}
</script>
</head>
<body>
<form name=my_form method=post>
<input type="text" onChange=check_length("my_form","my_text"); name=my_text rows=4 cols=30 value="">
<br>
<input size=1 value=50 name=text_num> Characters Left
</form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud) javascript ×2