javascript 焦点问题

来源:百度知道 编辑:UC知道 时间:2024/06/06 00:31:56
checkzifu.js

function checkzifu(zifuobj)
{
var checkStr = zifuobj;
var allValid = true;
var shu=new Array(4)
shu[0]=checkStr.indexOf("'")
shu[1]=checkStr.indexOf("<")
shu[2]=checkStr.indexOf(">")
shu[3]=checkStr.indexOf("[")
shu[4]=checkStr.indexOf("]")
for(var i=0;i<=4;i++)
{
if(shu[i]!=-1)
{
allValid=false
break
}
}
if (allValid==false)
{
return false
}
if (checkStr.length > 40)
{
return false;
}
return true
}
-----------------------------------------------------------------
-----------------------------------------------------------------
xxx.html
<script language="javascript" src="js/checkzifu.js"></script>
function checkzf()
{
var

form1.Ename.focus()
// form1 前面加 document
// 当你打开网页的时候,页面存在了window对象,然后出现了document对象,然后才是form表单。window是默认的,可以不写,记住一定要写document对象。

// 错误提示
try{
// 在这里写脚本,如果出错了,会弹出提示。
}
catch(e)
{
alert(e.message);
}

分低了,没耐心看咧