紧急求助js的焦点问题,请各位帮忙 function check(obj){ if(obj.value!="000000"){ obj.focus(); obj.style.backgroundColor="#FF0000"; alert("Error!"); }} 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <html><head> <title>Untitled</title><script language="javascript">var checked = false;function nextFocus(obj){ if(obj.value.length >= obj.maxLength){ check(obj); document.form1.txt2.focus(); }}function check(obj){ if(obj.value!="000000"){ obj.style.backgroundColor="#FF0000"; if(event.type=="blur") alert("Error!"); }}</script></head><body><form name="form1"><input type="text" name="txt1" maxlength="6" onkeyup="nextFocus(this)" onblur="check(this)"><input type="text" name="txt2"></form></body></html> 谢谢这么快就回复了。但是不好意思,刚才例子有点问题,实际是confirm对话框,如果点“OK”,就把焦点设回刚才check的控件;点“Cancle”就什么也不做(此时焦点和操作有关)。所以以上的方法就不好用了。function check(obj){ if(obj.value!="000000"){ obj.style.backgroundColor="#FF0000"; if(confirm("Edit it?")){ obj.focus(); } }} 刚看到hookee() 的方法,谢谢,已经解决 Hi,我想請問關於getElementById()的問題.. 禁用整个页面的标签 请问discuz的论坛程序在发表话题的时候上传附件的功能是怎么实现的? javascript创建select,看看这段代码的问题,谢谢 是否是this.blur()丢失的问题 希望高人指导,谢谢 急!解决这个问题马上就给分!谁解决就全给谁! 【老问题重现江湖】js编码转换问题,从utf8到gb2312互转 如何通过javascript动态加载select的子选项?! 关于IE10兼容性视图的问题 首页 JS+图片 方式 实现幻灯翻转新闻 ??? 四个文本域不能为空的问题。
<head>
<title>Untitled</title>
<script language="javascript">
var checked = false;
function nextFocus(obj){
if(obj.value.length >= obj.maxLength){
check(obj);
document.form1.txt2.focus();
}
}function check(obj){
if(obj.value!="000000"){
obj.style.backgroundColor="#FF0000";
if(event.type=="blur") alert("Error!");
}
}</script>
</head><body>
<form name="form1">
<input type="text" name="txt1" maxlength="6" onkeyup="nextFocus(this)" onblur="check(this)">
<input type="text" name="txt2">
</form>
</body>
</html>
function check(obj){
if(obj.value!="000000"){
obj.style.backgroundColor="#FF0000";
if(confirm("Edit it?")){
obj.focus();
}
}
}