In struts 1 tags for html:textarea here
I do not see a maxlength attribute. How can i restrict the user from entering more than 100 characters? Also why did struts 1 omit such a basic attribute?
In struts 1 tags for html:textarea here
I do not see a maxlength attribute. How can i restrict the user from entering more than 100 characters? Also why did struts 1 omit such a basic attribute?
Because this "basic attribute" wasn't even supported in IE before IE10, and was added in HTML 5.
Struts 1 predates that by a significant margin, has been EOL'd, and hasn't seen a new release for some time. Bear in mind that Struts 1.2's last release was, what, 2006-ish?
You may extract the TLD and modify it to allow arbitrary attributes under JSP 2.0:
<dynamic-attributes>true</dynamic-attributes>
Add the attribute using JS.
Put something like this after your textarea:
<script type="text/javascript">
document.getElementById('textarea-id').setAttribute('maxlength', '512');
</script>
Because this "basic attribute" wasn't even supported in IE before IE10, and was added in HTML 5.
Struts 1 predates that by a significant margin, has been EOL'd, and hasn't seen a new release for some time. Bear in mind that Struts 1.2's last release was, what, 2006-ish?
You may extract the TLD and modify it to allow arbitrary attributes under JSP 2.0:
<dynamic-attributes>true</dynamic-attributes>
styleId
attribute to the html:textarea
, struts will not accept id
attribute.add Javascript to limit the length after that
<html:textarea styleId="contactText" property="contactText" cols="55" rows="10"/>
<script type="text/javascript">
document.getElementById('contactText').setAttribute('maxlength', '10');
</script>
You may use maxlength="100"
within the text area or input in JSP, or else you have to customize validator.xml.
In validator.xml:
<field property="propertyname" depends="maxlength">
<var-name>maxlength</var-name>
<var-value>100</var-value>
</var>
<msg key="propertyname.maxlength" name="maxlength" />
</field>
In Application.proprties:
propertyname.maxlength = <tr><td colspan\="2" class\="note">Please make sure that FieldName is only maximum 100 characters.</td></tr>
© 2022 - 2024 — McMap. All rights reserved.