本文介绍了Spring形式:输入HTML5必填属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Spring表单,并且想使用Spring表单似乎不支持的HTML5'required'属性.
I am using Spring forms and would like to use the HTML5 'required' attribute which Spring forms does not seem to support.
<form:input path="someinput" cssClass="required"/>
我似乎做不到
<form:input path="someinput" cssClass="required" required="required"/>
,因为Spring TLD当前不支持此功能.
as this is currently not supported by the Spring TLD.
如果我想使用完整的HTML5规范,似乎需要放弃弹簧形式
It seems like I NEED to ditch spring forms if I want to use the full HTML5 spec
<input name="someinput" id="someinput" class="required" required="required"></input>
有人知道我如何用spring形式3.1.3.RELEASE实现所需的字段吗?谢谢!
Does anyone know how I can implement the required field with spring forms 3.1.3.RELEASE?Thanks!
推荐答案
只需在页面末尾添加一些jquery
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>
这篇关于Spring形式:输入HTML5必填属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!