1.css实现原生form表单label必填选项红色*样式代码如下(示例):
- class="isCross comItem" required>
- <label for="isCross">是否涉及跨境业务:label>
- <div class="content">
- <div>
- <input type="radio" name="isCross" />
- <span>是span>
- div>
- div>
- <div>
- <input type="radio" name="isCross" />
- <span>否span>
- div>
-
- .comItem[required="required"] label:before {
- color: red;
- content: "*";
- position: absolute;
- margin-left: -15px;
- }
js控制必填校验
参考原文