[TOC]
## 表单错误提示
### 让对象标题标红
```
$common.Form_err($("input[name='leaveTime']"));
```
### 重置错误提示
```
//重置错误
$common.Form_err_reset();
```
## 自动组装表单
```
var new_data=$common.getFormData($("#ea55_form"));
console.log(JSON.stringify(new_data));
```
### 演示编辑表单即重置:
```
function Form_err_one(){
$('input').bind('input propertychange', function() {
$common.Form_err_reset();
});
$('textarea').bind('input propertychange', function() {
$common.Form_err_reset();
});
$('select').change(function() {
$common.Form_err_reset();
})
}
```
### 演示
```
<form id="ea55_form">
<input type="text" name="id" placeholder="输入ID" value="1" >
<input type="text" name="arr[]" placeholder="支持数组" value="数组1" >
<input type="text" name="arr[]" placeholder="支持数组" value="数组2" >
<input type="hidden" name="positivePhoto" value="{{=$common.ea55_null(my_data.positivePhoto)||''}}">
</form>
<script>
function ea55_tijiao(){
var new_data=$common.getFormData($("#ea55_form"));
if(!new_data['leaveBeginTime']){
$common.Form_err($("input[name='leaveBeginTime']"));
api.toast({
msg: '开始时间不能为空',
duration: 2000,
location: 'bottom'
});
return false;
}
console.log(JSON.stringify(new_data));
}
</script>
```
## 提交表单演示
```
function ea55_tijiao(){
return false;
var new_data=$common.getFormData($("#ea55_form"));
if(!new_data['leaveEndTime']){
$common.Form_err($("input[name='leaveEndTime']"));
api.toast({
msg: '结束时间不能为空',
duration: 2000,
location: 'bottom'
});
return false;
}
console.log(JSON.stringify(new_data));
$common.ajax({
url: 'v1/driver/addLeave',
app_url:true,
method: 'post',
not_loading:false,
show_loader:true,
verification_token:true,
data: {
values: new_data
}
}, function(ret, err) {
if (ret) {
console.log(JSON.stringify(ret));
if(ret.code&&ret.code==200){
ea55_fabuchenggong({},function(ret){
// console.log(JSON.stringify(ret));
if(ret.index==1){
//详情
}else{
ea55_guanbi();
}
});
}else{
}
} else {
console.log(JSON.stringify(err));
}
});
}
```