实现给必填项前添加红色星号
html
<div class="form-group">
<label class="col-sm-3 control-label calss名字">活动名称:</label>
<div class="col-sm-8">
<input name="activityName" th:field="*{activityName}" class="form-control" type="text" maxlength="15" placeholder="1~15字内">
</div>
</div>
<style>
label.calss名字::before {content: '* ';color: red;} //如需要指定特定的添加,在页面元素内添加相应class名字即可
</style>
实现效果
本文只是做展示效果,具体校验需要自行添加参数必填校验
转载来源:https://blog.csdn.net/weixin_39681426/article/details/105767059