sovals获取表单值
说明
- 获取整个form表单的值,返回json键值对数据
$(form).sovals(dataToString)
- 参数
dataToString
:是否将同名数据以, 隔开组成的字符串组成。 - 框架已包装在表单
.form-validate
中,点击按钮.btn-easyFormSubmit
,验证通过后返回数据
示例代码
var result = $('.form-addOne').sovals();
//返回form整个信息:{userName:'zhangS',name:'张三',namePinyin:'zs',cardType:'1'}
<!-- 页面表单 -->
<form class="soform form-validate form-enter form-addOne pad-t15" role="form" method="post" action="json/true.js">
<div class="row">
<div class="p6"><div class="item-one">
<label class="lab-item">用户名:</label>
<input class="txt txt-validate" type="text" name="userName" placeholder="用户名" noNull="请输入用户名" validType=many['username["请输入正确的用户名"]','maxlength[4,"用户名不能超过4个字符"]'] />
</div></div>
<div class="p6"><div class="item-one">
<label class="lab-item">姓名:</label>
<input id="nameChinese" class="txt txt-validate" type="text" name="name" noNull="请输入姓名" />
</div></div>
</div>
<div class="row">
<div class="p6"><div class="item-one">
<label class="lab-item">拼音码:</label>
<input id="namePinyin" class="txt txt-validate" type="text" name="namePinyin" placeholder="姓名拼音码" noNull="请输入姓名拼音码" />
</div></div>
<div class="p6"><div class="item-one">
<label class="lab-item">证件类型:</label>
<select id="cardType" class="so-select txt-validate" name="cardType" noNull="请选择证件类型" data-opt="{url:'json/cardtype.js',data:{type:1},value:1,success:function(val,_self,opt){console.log(val,opt);},change:function(val,_self,opt){console.log(val);}}">
</select>
</div></div>
</div>
<p class="row-btn center">
<input type="button" class="btn btn-primary btn-easyFormSubmit" lay-submit name="btnSubmit" value="保存" />
<input type="button" class="btn btn-primary disabled" lay-submit name="btnSubmit" value="立即保存" />
<input type="button" class="btn btn-cancel" name="btnCancel" value="取 消" />
</p>
</form>