2011-12-15 141 views
0
<tr class="searchrow1"> 
      <td class="createcolumn1" > 
          <font class="texto1"><bean:message key="booktypForm.booktypDesc"/>:</font> 
        </td> 
        <td class="createcolumn2" > 

          <html:textarea property='restypDesc' style="width:189%" readonly='<%= viewflag %>' tabindex='3' accesskey='k' onfocus="highlight(event)" onchange="validateField(restypDesc,'numstr','chk',1,100,'imgbooktypDesc',0);"/> 
          <c:set var="errorMsg" value="${requestScope.restypDesc}"/> 
          <c:choose> 
          <c:when test="${not empty errorMsg}"> 
           <img id="imgbooktypDesc" src="<c:url value='/images/tooltip/error.png'/>" width='19.5' height='19.5' align='top' border='0' onMouseover="ddrivetip('<html:errors property="booktypDesc"></html:errors>','<bean:message key="tooltip.server.size"/>','<bean:message key="tooltip.server.color"/>')" onMouseout="hideddrivetip()" > 
          </c:when> 
          <c:otherwise> 
           <img id="imgbooktypDesc" style="visibility:hidden" src="<c:url value='/images/tooltip/error.png'/>" width='19.5' height='19.5' align='top' border='0' onMouseover="ddrivetip(message,'<bean:message key="tooltip.client.size"/>','<bean:message key="tooltip.client.color"/>');" onMouseout="hideddrivetip()" > 
          </c:otherwise> 
          </c:choose>         
        </td> 
        </tr> 

正如您從上面的代碼片段中看到的,這是JSP中的文本框。該文本框用於填充描述並最終存儲在數據庫中。但是,數據庫字段的最大長度是100個字。我通過Javascript驗證了這個限制,但是如果我輸入超過100個單詞,那麼文本框的寬度會自動增加。任何幫助?我的JSP中的HTML文本輸入長度自動增加

感謝enter image description here

+0

你有`style =「width:189%」`這是一個可能的罪魁禍首。 – Interrobang 2011-12-15 05:36:17

回答

1

你嘗試設置CSS最大寬度?

0

如果要實時控制文本框內容的長度,可以使用oninput事件來評估和限制每次輸入更改時的輸入長度。看到這個演示:http://jsfiddle.net/LJ3PK/