[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));
}
});
}
```