Spring forms:input HTML5 required attribute

前端 未结 2 394
天涯浪人
天涯浪人 2021-01-25 09:51

I am using Spring forms and would like to use the HTML5 \'required\' attribute which Spring forms does not seem to support.



        
相关标签:
2条回答
  • 2021-01-25 09:58
    1. If you just submit the form with default commandName, your approach is ok.
    2. Better way to solve it: Write the form with spring-form and forget the required thing. Then find out what the real html spring-form generated for you. Write the html your own and add the required field.
    0 讨论(0)
  • 2021-01-25 10:16

    just add some jquery at the end of the page

        <html>
        <body>
                <form:input path="someinput" id="someinput"/>
        </body>
        <script>
                $("#someinput").attr('required', ''); 
        </script>
        </html>
    
    0 讨论(0)
提交回复
热议问题