Fix Input Validation for Forms

This commit is contained in:
Mouhamed Lamine
2018-07-28 13:32:41 +08:00
parent d220464627
commit 9e22ace016
4 changed files with 48 additions and 6 deletions
@@ -208,6 +208,27 @@
},
methods: {
generateReport(formName) {
if ((this.supplierBookingForm.rate < 0) || isNaN(this.supplierBookingForm.rate)) {
this.$message({
message: 'Rate must be digits only',
type: 'warning'
})
return
}
if ((this.supplierBookingForm.rebate < 0) || isNaN(this.supplierBookingForm.rebate)) {
this.$message({
message: 'Rebate must be digits only',
type: 'warning'
})
return
}
if ((this.supplierBookingForm.transfer_amount < 0) || isNaN(this.supplierBookingForm.transfer_amount)) {
this.$message({
message: 'Amount must be a number greater than 0',
type: 'warning'
})
return
}
this.loading_btn = true
this.$refs[formName].validate((valid) => {
@@ -216,6 +216,13 @@
},
methods: {
submitChinaSlip(formName) {
if ((this.chinaSlipForm.actual_transfer_amount < 0) || isNaN(this.chinaSlipForm.actual_transfer_amount)) {
this.$message({
message: 'Transfer Amount must be a number greater than 0',
type: 'warning'
})
return
}
this.loading_btn = true
this.$refs[formName].validate((valid) => {
@@ -251,6 +251,13 @@ export default {
this.dialogVisible = true
},
submitUserSlip (formName) {
if ((this.user_slip_form.transfer_amount < 0) || isNaN(this.user_slip_form.transfer_amount)) {
this.$message({
message: 'Amount must be a number greater than 0',
type: 'warning'
})
return
}
this.loading = true
this.$refs[formName].validate((valid) => {
if (valid) {
+13 -6
View File
@@ -153,7 +153,7 @@
<el-input v-model="bookingForm.bank_branch" type="text" placeholder="Branch / 分行/支行" style="width: 80%" />
</el-form-item>
<el-form-item prop="account_num">
<el-input v-model="bookingForm.account_num" type="text" placeholder="Account Number / AliPay_ID / WechatPay_ID" style="width: 80%"
<el-input type="text" v-model="bookingForm.account_num" placeholder="Account Number / AliPay_ID / WechatPay_ID" style="width: 80%"
/>
</el-form-item>
<el-form-item>
@@ -363,11 +363,11 @@ export default {
message: 'Please input branch',
trigger: 'change'
}],
account_num: [
{required: true,
message: 'Please input account number'},
{number:true,
message: 'Account number cannot be text'}
account_num: [{
required: true,
message: 'Please input account number',
trigger: 'change'
}
]
},
term: '',
@@ -497,6 +497,13 @@ export default {
},
// Get calculation before submitting booking
getCalculationValue (formName) {
if ((this.bookingForm.account_num < 0) || isNaN(this.bookingForm.account_num)) {
this.$message({
message: 'Issue with Last input: Account number must be a valid China bank account number',
type: 'warning'
})
return
}
this.loading = true
this.$refs[formName].validate((valid) => {
if (valid) {