2011-12-15 142 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/