<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
<body bottommargin="0" leftmargin="0" topmargin="0" rightmargin="0" ms_positioning="GridLayout"
onunload="return pageunload()">
<form name="Form1">
<table>
<tr>
<td>
<input name='ProNum_1' class='justify' type='text' style='ime-mode: disabled; width: 60px;'
onblur ='javascript:GetSum(1)' onkeypress='return floatkey()'>
</td>
<td>
<input name='price_1' class='justify' type='text' style='ime-mode: disabled; width: 60px;'
onkeypress='return floatkey()'>
</td>
</tr>
<tr>
<td>
<input name='ProNum_2' class='justify' type='text' style='ime-mode: disabled; width: 60px;'
onblur='javascript:GetSum(2)' onkeypress='return floatkey()'>
</td>
<td>
<input name='price_2' class='justify' type='text' style='ime-mode: disabled; width: 60px;'
onkeypress='return floatkey()'>
</td>
</tr>
</table>
</form>
</body>
< ml><script language="javascript">
function GetSum(rowid)
{
var ProNum=eval("document.Form1.ProNum_"+rowid).value;
if (ProNum=="")
{
alert("请输入数量!");
eval("document.Form1.ProNum_"+rowid).focus();
return false;
}
}
</script>目的是强制用户数量一栏必须输入。
第一行获得光标时,如果用户不输入直接点下一行数量那一栏就会一直弹出请输入数量产生死循环。
望指点focus() onblur结合使用产生死循环如何解决。
<html>
<body bottommargin="0" leftmargin="0" topmargin="0" rightmargin="0" ms_positioning="GridLayout"
onunload="return pageunload()">
<form name="Form1">
<table>
<tr>
<td>
<input name='ProNum_1' class='justify' type='text' style='ime-mode: disabled; width: 60px;'
onblur ='javascript:GetSum(1)' onkeypress='return floatkey()'>
</td>
<td>
<input name='price_1' class='justify' type='text' style='ime-mode: disabled; width: 60px;'
onkeypress='return floatkey()'>
</td>
</tr>
<tr>
<td>
<input name='ProNum_2' class='justify' type='text' style='ime-mode: disabled; width: 60px;'
onblur='javascript:GetSum(2)' onkeypress='return floatkey()'>
</td>
<td>
<input name='price_2' class='justify' type='text' style='ime-mode: disabled; width: 60px;'
onkeypress='return floatkey()'>
</td>
</tr>
</table>
</form>
</body>
< ml><script language="javascript">
function GetSum(rowid)
{
var ProNum=eval("document.Form1.ProNum_"+rowid).value;
if (ProNum=="")
{
alert("请输入数量!");
eval("document.Form1.ProNum_"+rowid).focus();
return false;
}
}
</script>目的是强制用户数量一栏必须输入。
第一行获得光标时,如果用户不输入直接点下一行数量那一栏就会一直弹出请输入数量产生死循环。
望指点focus() onblur结合使用产生死循环如何解决。
解决方案 »
- 请问这两个对象为什么不相等啊
- javascript中如何查看对象的已经添加了的事件处理函数
- Ext中Combox的诡异问题
- 我用onMouseOver="this.style.backgroundColor='#1b1e89'" 实现鼠标移动改变背景颜色,为什么...
- A到Z的循环
- firefox里不支持onChange事件,我想实现这个功能该怎么做?
- 这个用正则表达式怎么处理?在线等。急
- JS如何判断我传递的参数是不是event事件对象?
- 学好JAVASCRIPT 关键在哪
- 获取和修改页面json对象属性的值
- 怎样修改这个button的值呢,他本身写在了js中。
- 关于jquery 里面tabs的隐藏和显示
建议放弃这种方法,改为在提交时进行验证!
如果真有非强制输入不可的理由,不要用alert弹出提示,采用在输入框边上显示DIV进行提示就不会有这种现象了。
<script language="javascript">
var currentID=null;
function GetSum(rowid)
{
var ProNum=eval("document.Form1.ProNum_"+rowid).value;
if (ProNum=="")
{
if(currentID==null||currentID==rowid)
{
alert("请输入数量!");
eval("document.Form1.ProNum_"+rowid).focus();
currentID=rowid;
return false;
}
else
{
currentID=null;
}
}
}
</script>