java吧 关注:1,263,227贴子:12,762,651
  • 13回复贴,共1

onkeyup判断2个文本框的值得大小

只看楼主收藏回复

股本 <input type="text" name="bean.stockTotalAmount" maxlength="25" value="${bean.stockTotalAmount}"/>
持有数量:<input type="text" name="bean.stockAmount" maxlength="20" value="${bean.stockAmount}">
我想判断 如果持有数量大于总股本的时候,责提示, 这个怎么做?? 请高手求救!!


1楼2011-11-30 16:52回复
    那位大哥帮帮忙啊!!!!


    2楼2011-11-30 23:30
    回复
      2025-06-08 11:43:35
      广告
      应该是
      var a =document.getElementById("quantity").value;
      var b=document.getElementById("total").value;
      if(a > b ){
      alert("数量要小于总股本");
      return false;
      }
      但是他老是不提示。着个我就晕了。 求高手讲解


      3楼2011-11-30 23:33
      回复
        <input type="text" name="bean.stockAmount" maxlength="20" value="${bean.stockAmount}" onblur="function();">function这个写上你要触发的事件。
        或者你可以使用onchange如果使用onchange需要你修改脚本。


        IP属地:浙江4楼2011-12-01 09:12
        回复
          你感觉我的不是么? 我用的是onblur=“a();”
          function a(){
          var a =document.getElementById("quantity").value;
          var b=document.getElementById("total").value;
          if(a > b ){
          alert("数量要小于总股本");
          return false;
          }
          }
          你的意思是这样的吧? 你感觉我用的不是这个??


          5楼2011-12-01 09:35
          回复

            function a(){
            alert("step in function");
            var a =document.getElementById("quantity").value;
            var b=document.getElementById("total").value;
            if(a > b ){
            alert("数量要小于总股本");
            return false;
            }
            }
            你看下能不能进入到函数当中


            IP属地:浙江6楼2011-12-01 10:28
            回复
              不行。。 我的alert 都提示不出来。。。 为什么呢? 放在什么地方都提示不出来 


              7楼2011-12-01 15:43
              回复
                我把你的代码测试了下,米有问题可以正常显示的!你老的两个文本框都没加上id,请问脚本怎么能找到?


                IP属地:浙江8楼2011-12-01 15:58
                回复
                  2025-06-08 11:37:35
                  广告
                  我么有ID的话,那个document.getElementById("quantity").value; 的quantity 哪里能获取到的。。。我让你看看我的代码。你就知道了。我给你发全部代码。


                  9楼2011-12-01 16:07
                  回复
                    那你把代码全部贴出来


                    IP属地:浙江10楼2011-12-01 16:08
                    回复
                      var codeDom = document.getElementById(tempCode); //用于显示匹配值的容器
                      var inputDom=document.getElementById(tempName);
                      auFix.init(inputDom,codeDom,dom);
                      }
                      </script>
                      </head>
                      <body class="modalwin1">
                      <form name="generalForm" method="post" action="${pageContext.request.contextPath}/sts/models/glq/xzqd/zyg/listStockList.action?type=${type}">
                      <table width="100%" border="1" cellpadding="3" cellspacing="0" bordercolor="#CCCCCC" style="border-collapse:collapse" >
                      <tr>
                      <td align="right" nowrap bgcolor="#F3F3F3" class="datacell">业务分类</td>
                      <td class="datacell">
                      <c:if test="${zygType==1}">
                      自营业务
                      <input type="hidden" name="bean.businessType" value="1">
                      </c:if>
                      <input type="hidden" name="type" value="${type}">
                      <input type="hidden" name="zygType" value="${zygType}">
                      <c:if test="${zygType == 0}">
                      <select name="bean.businessType">
                      <option value="2" <c:if test='${bean.businessType == 2}'>selected</c:if>>**资产管理业务</option>
                      <option value="3" <c:if test='${bean.businessType == 3}'>selected</c:if>>定向资产管理业务</option>
                      </select>
                      </c:if>
                      <input type="hidden" name="bean.id" value="${bean.id}">
                      </td>
                      <!--
                      <td align="right" nowrap bgcolor="#F3F3F3" class="datacell">产品编号(<font color="red">*</font>)</td>
                      <td class="datacell">
                      <input type="text" name="bean.fundCode" value="${bean.fundCode}">
                      </td>
                      <td align="right" nowrap bgcolor="#F3F3F3" class="datacell">产品名称(<font color="red">*</font>)</td>
                      <td class="datacell">
                      <input type="text" name="bean.fundName" value="${bean.fundName}" >
                      </td>
                      -->
                      <td align="right" nowrap bgcolor="#F3F3F3" class="datacell">股票名称(<font color="red">*</font>)</td>
                      <td class="datacell">
                      <input type="text" id="stockName" maxlength="20" name="bean.stockName" value="${bean.stockName}">
                      </td>
                      <td align="right" nowrap bgcolor="#F3F3F3" class="datacell">股票代码(<font color="red">*</font>)</td>
                      <td class="datacell">
                      <input type="text" id="stockCode" maxlength="6"
                      <c:if test="${empty bean.stockCode}">
                      </c:if>
                      name="bean.stockCode" value="${bean.stockCode}">
                      <div id="tip" style="color:red;display:none;">此股票号码已经存在!</div>
                      </td>
                      </tr>
                      <tr>
                      <td align="right" nowrap bgcolor="#F3F3F3" class="datacell">市场类别</td>
                      <td class="datacell">
                      <select name="bean.markerType">
                      <option value="1" <c:if test="${bean.markerType == 1}"> selected </c:if>>上海</option>
                      


                      13楼2011-12-01 16:10
                      回复
                        <option value="2" <c:if test="${bean.markerType == 2}"> selected</c:if>>深圳</option>
                        </select>
                        </td>
                        <td align="right" nowrap bgcolor="#F3F3F3" class="datacell">持有数量(<font color="red">*</font>)</td>
                        <td class="datacell">
                        <input type="text" name="bean.stockAmount" maxlength="30" value="${bean.stockAmount}">
                        </td>
                        <td align="right" nowrap bgcolor="#F3F3F3" class="datacell">总股本(<font color="red">*</font>)</td>
                        <td class="datacell">
                        <input type="text" name="bean.stockTotalAmount" maxlength="30" value="${bean.stockTotalAmount}">
                        </td>
                        </tr>
                        <tr>
                        <td align="right" nowrap bgcolor="#F3F3F3" class="datacell" >收盘价(<font color="red">*</font>)</td>
                        <td class="datacell" colspan="5">
                        <input type="text" name="bean.closePrice" maxlength="7" value="${bean.closePrice}">
                        </td>
                        <!-- <td align="right" nowrap bgcolor="#F3F3F3" class="datacell" >资金账号(<font color="red">*</font>)</td>
                        <td class="datacell" colspan="3">
                        <input type="text" name="bean.fundCode" value="${bean.fundCode}">
                        </td>
                        -->
                        </tr>
                        </table>
                        <c:if test="${empty bean.id}">
                        <input type="hidden" name="bean.isMunualData" value="1">
                        </c:if>
                        <c:if test="${!empty bean.id}">
                        <input type="hidden" name="bean.isMunualData" value="${bean.isMunualData}">
                        </c:if>
                        <table width="100%">
                        <tr>
                        <td width="70%" nowrap class="datacell"></td>
                        <td width="10%" nowrap class="datacell" align="right">
                        <div type="button" label="提交" action="submitForm()" />
                        </td>
                        <td width="10%" nowrap class="datacell" align="left">
                        <div type="button" label="返回" action="javascript:history.go(-1);" />
                        </td>
                        </tr>
                        </table>
                        <div id="chDom" style="visibility:hidden" class="divDom"></div>
                        </form>
                        <script type="text/javascript">
                        var oo=new mSift('oo',20,'stockCode','stockName');
                        oo.Create(document.getElementById('stockName'));
                        </script>
                        </body>
                        </html>
                        全部代码! 判断持有数量和总股本。


                        14楼2011-12-01 16:10
                        回复
                          这样吧你的QQ是什么?下班回去帮你看


                          IP属地:浙江16楼2011-12-01 16:27
                          回复
                            恩,好的! 我QQ:171970663 谢谢了


                            17楼2011-12-01 16:29
                            回复