普通表单必填验证
1.增加lay-verify="required"即可
- <textarea lay-verify="required" required id="abnormalDescription"
- placeholder="请输入"
- class="layui-textarea"></textarea>
select下拉必填
正常使用
增加lay-verify=“required”
增加请输入性别,给select给定一个默认值
- <div class="layui-form-item">
- <label class="layui-form-label">性别</label>
- <div class="layui-input-inline">
- <select name="sex" lay-verify="required">
- <option value="">请输入性别</option>
- <option value="0">男</option>
- <option value="1">女</option>
- </select>
- </div>
- </div>
Vue版本
在打开页面的时候,给fltAbnormalEvent.importance设置值为”“即可,默认值应该是undefined,不是layui所期待的"" 字符串所以不生效
- <div class="layui-input-block">
- <select lay-verify="required" required id="importance" v-model="fltAbnormalEvent.importance" class="layui-input-block"
- >
- <option value=""></option>
- <option value="1">重要</option>
- <option value="https://files.jxasp.com/image/2">普通</option>
- </select>
- </div>
Xmselect必填
增加layVerify: ‘required’,
layVerType: ‘tips’,即可
- this.sendToCompany = xmSelect.render({
- el: '#sendToCompany',
- layVerify: 'required',
- layVerType: 'tips',
- data: []
- })