Search code examples
javaspringspring-mvcmaxlength

How to use Maxlength in Spring <Form:Input> tag?


I am stuck with issue of setting 'Maxlength' to Spring 'Form:Input' tag. It is not reflecting in HTML

Spring Code:

<form:input path="admin[${loop.index}].firstName" id="firstName${loop.index}" cssClass="required"  maxlength="64" />

Output in Browser:

<input name="admin[0].firstName" type="text" class="required" aria-required="true" aria-invalid="false">

Is there any way to set the same (if not prefer CSS or JQuery)?


Solution

  • Converting comment to answer

    Spring <form input> tag supports maxlength here is the document:

    Spring tag library supports almost all the jsp attributes with some extra feature to binding which helps us in mapping the values or in validation.

    Spring will not manipulate anything which is provided in jsp. It just shows in browser, but before that if any jQuery code or javascript code is manipulated the tag then it will show the manipulated tag instead of actual.

    In your case it may be jQuery.