Skip to content
On this page

表单提交

默认表单提交

html
<form>
	<div id="demo1" class="xm-select-demo"></div>
	<button class="btn" type="submit">提交</button>
</form>

<script>
var demo1 = xmSelect.render({
	el: '#demo1', 
	data: [
		{name: '张三', value: 1},
		{name: '李四', value: 2},
		{name: '王五', value: 3},
	]
})

</script>

修改name, 表单验证

js
{
	name: 'lalalalalala',
	layVerify: 'required',
	layVerType: 'tips',
}
html
<form class="layui-form">
	<div id="demo2" class="xm-select-demo"></div>
	<button class="btn" type="submit" lay-submit>提交</button>
	<button class="btn" type="reset">重置</button>
</form>

<script>
var demo2 = xmSelect.render({
	el: '#demo2', 
	name: 'lalalalalala',
	layVerify: 'required',
	layVerType: 'msg',
	data: [
		{name: '张三', value: 1},
		{name: '李四', value: 2},
		{name: '王五', value: 3},
	]
})

</script>