当前位置:网站首页>The El form item contains two inputs. Verify the two inputs
The El form item contains two inputs. Verify the two inputs
2022-06-26 12:57:00 【weixin_ forty-nine million thirty-five thousand four hundred an】

This is the demand :
1. Maximum input 999( Integers )
2. Can't be empty , Fill in at least one item
3. The maximum value must be greater than the minimum value
4. You can select month, year and day , One year according to 365 Day count , January by 30 Day count
<el-form-item
v-if="ruleForm.goodsWay === 1"
label=" Shelf life range "
:error="cuePriceRateError"
>
<el-col
:span="6"
style="padding-left:0"
>
<el-form-item
prop="endTime"
>
<el-input
v-model="ruleForm.startTime"
style="width:150px"
type="number"
onkeypress="return (/[\d]/.test(String.fromCharCode(event.keyCode)));"
@change="onStartTimeChange"
@blur="onStartTimeChange"
>
<el-select
slot="append"
v-model="ruleForm.startOpt"
style="width:58px"
@change="dataOtherRules"
>
<el-option
v-for="{value, label} of timeOptionsList"
:key="value"
:label="label"
:value="value"
/>
</el-select>
</el-input>
</el-form-item>
</el-col>
<el-col :span="1">
~
</el-col>
<el-col :span="6">
<el-form-item
prop="endTime"
>
<!-- onkeypress="return (/[\d]/.test(String.fromCharCode(event.keyCode)));"
This code is to control the input of non numeric -->
<el-input
v-model="ruleForm.endTime"
type="number"
onkeypress="return (/[\d]/.test(String.fromCharCode(event.keyCode)));"
style="width:150px"
@change="onEndTimeChange"
@blur="onEndTimeChange"
>
<el-select
slot="append"
v-model="ruleForm.endOpt"
style="width:58px"
@change="dataOtherRules"
>
<el-option
v-for="{value, label} of timeOptionsList"
:key="value"
:label="label"
:value="value"
/>
</el-select>
</el-input>
</el-form-item>
</el-col>
<el-col :span="11">
( January =30 God , A year =365 God )
</el-col>
</el-form-item>
// It's on it html Two input boxes and two drop-down boxes
data: {
return {
cuePriceRateError: '',
}
}
// Method :
cptTime(val) {
switch (val) {
case 1: return 365;
case 2: return 30;
case 3: return 0;
default: return 0;
}
},
onStartTimeChange() {
this.dataOtherRules();
},
onEndTimeChange() {
this.dataOtherRules();
},
// 1. First judge whether the two boxes are empty , If all are empty
// 2. It is necessary to judge whether the input of one item and two items is greater than 999
// 3. If you enter both , And none of them is greater than 999, Judge whether the former item is greater than the latter item
// 4. Here is just a hint , It doesn't really prevent form submission , To prevent judging when submitting this.cuePriceRateError Whether it is empty is OK
dataOtherRules() {
const isEmpty = (val) => (val === undefined) || (val === '');
let startTime = this.ruleForm.startTime;
let endTime = this.ruleForm.endTime;
// If both items are not entered
if (isEmpty(startTime) && isEmpty(endTime)) {
this.cuePriceRateError = ' Please enter at least one item ';
} else if ((!isEmpty(startTime) && !isEmpty(endTime))) {
if (startTime * 1 > 999 || endTime * 1 > 999) {
this.cuePriceRateError = ' Maximum input 999';
return;
} else {
this.cuePriceRateError = '';
}
// If both have values , Start making comparisons
const startOpt = this.ruleForm.startOpt;
const endOpt = this.ruleForm.endOpt;
if (startOpt === 1 || startOpt === 2) {
startTime *= this.cptTime(startOpt);
}
if (endOpt === 1 || endOpt === 2) {
endTime *= this.cptTime(endOpt);
}
// If the end time is greater than the start time
if (startTime * 1 >= endTime * 1) {
this.cuePriceRateError = ' The end time must be greater than the start time ';
} else {
this.cuePriceRateError = '';
}
} else if ((!isEmpty(startTime) || !isEmpty(endTime))) {
// The maximum judgment is 999
if (startTime * 1 > 999 || endTime * 1 > 999) {
this.cuePriceRateError = ' Maximum input 999';
} else {
this.cuePriceRateError = '';
}
} else {
this.cuePriceRateError = '';
}
},
边栏推荐
- 无人机遥感在森林监测的部分应用研究案例总结
- nvm安装教程
- [solved] data duplication or data loss after laravel paginate() paging
- 【网络是怎么连接的】第二章(上): 建立连接,传输数据,断开连接
- NoSQL mongodb - 04 mongodb database and web service combination case
- Php+laravel5.7 use Alibaba oss+ Alibaba media to process and upload image / video files
- NoSQL mongodb - 02 mongodb server installation, mongodb shell, basic concepts and visualization tools
- Redis learning - 06 drifting bottle case
- Less than 40 lines of code to create a blocprovider
- 洛谷P3426 [POI2005]SZA-Template 题解
猜你喜欢

power designer - 自定义注释按钮
![[solved] laravel completes the scheduled job task (delayed distribution task) [execute a user-defined task at a specified time]](/img/13/c2c63333a9e5ac08b339449ea17654.jpg)
[solved] laravel completes the scheduled job task (delayed distribution task) [execute a user-defined task at a specified time]

环形队列php

第十章 设置结构化日志记录(二)

File remote synchronization and backup artifact Rsync

Several rare but useful JS techniques

Word文档导出(使用固定模板)

Fengshentai old shooting range Kali series

Laravel+gatewayworker completes the im instant messaging and file transfer functions (Chapter 4: server debugging errors)

Lightflow completed the compatibility certification with "daocloud Enterprise Cloud native application cloud platform"
随机推荐
文件远程同步、备份神器rsync
Php+laravel5.7 use Alibaba oss+ Alibaba media to process and upload image / video files
Wechat applet wx Request request encapsulation
7-16 货币系统Ⅰ
【Spark】.scala文件在IDEA中几种图标的解释
MySQL 自定义函数时:This function has none of DETERMINISTIC, NO SQL 解决方案
A must for programmers, an artifact utools that can improve your work efficiency n times
Tiger DAO VC产品正式上线,Seektiger生态的有力补充
数字信号处理——线性相位型(Ⅰ、Ⅲ型)FIR滤波器设计(1)
processsing 函数random
【网络是怎么连接的】第二章(中):一个网络包的发出
[solved] laravel completes the scheduled job task (delayed distribution task) [execute a user-defined task at a specified time]
Thinkphp5 query report: sqlstate[hy093]: invalid parameter number
Research on the current situation of China's modified engineering plastics market and demand forecast analysis report 2022-2028
7-2 数的三次方根
[solved] data duplication or data loss after laravel paginate() paging
面试题积累
无人机遥感在森林监测的部分应用研究案例总结
中科软外包一面
老司机总结的12条 SQL 优化方案(非常实用)