in my jsp, but when I check ...">

Spring form: input for number

I am using the Spring form: input as shown below:

<form:input type="number" .....> 

in my jsp, but when I check the html that is displayed in the browser, it looks like this:

 type="number" type="text" 

i., two type attributes are generated in html.

On the other hand, if I check with the option to check the item in the browser, it shows correctly - only type="number" , as expected.
Edit - My question is: Why do I get two type attributes in the generated html ( type="number" type="text" )? How to solve it?

+7
html spring-form jsp jsp-tags
source share
2 answers
Tag

Spring form:input does not have an attribute named type , and type=number used in your code belongs to the html5 input tag

Also see HTML text input only numeric input

Spring form tld lists the valid attributes of the form:input element here

+6
source share

HTML 5 with <!DOCTYPE html> has its own solution :

<input type="number">

Beware that does not work in the standard way in some browsers .

Try input type = "number" to see the HTML5 version in action.

See also https://github.com/jonstipe/number-polyfill for transparent support in older browsers.

0
source share

All Articles