javascript - v 形式的条件句
问题描述
我对 vue.js 很陌生。我正在尝试对文本字段应用一些验证。这是表格的样子。
我需要应用一些条件,以便如果用户输入源 IP 但未输入目标 IP,则需要目标端口,但是如果用户输入源 IP 和目标 IP,则不需要目标端口。可能吗?
代码:
<template>
<v-container fluid>
<v-card class="ma-3 pa-3">
<v-card-title primary-title>
<div class="headline primary--text">Firewall Logs</div>
</v-card-title>
<v-card-text>
<v-form v-model="valid" ref="form" lazy-validation>
<v-text-field
label="Source IP"
v-model="sourceip"
v-validate="'required_if|ip'"
data-vv-name="sourceip"
:error-messages="errors.collect('sourceip')"
required
></v-text-field>
<v-text-field
label="Destination IP"
v-model="destinationip"
v-validate="'required_if: '"
data-vv-name="destinationip"
:error-messages="errors.collect('destinationip')"
required
></v-text-field>
<v-text-field
label="Destination Port"
v-model="destinationport"
v-validate="{ regex: /^(\*[0-9]{1,4}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])$/}"
data-vv-name="destinationport"
hint="Enter port number between 0 and 65535 or '*' if port is unknown"
:error-messages="errors.collect('destinationport')"
></v-text-field>
<v-select
item-value="string"
v-model="day"
:items="days"
label="Days To Search"
hint="Go back up to 7 days to expand the query"
v-on:change="reset"
></v-select>
</v-form>
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn small color="error" @click="cancel">Cancel</v-btn>
<v-btn small color="warning" @click="reset">Reset</v-btn>
<v-btn small color="success" @click="submit" :disabled="!valid">
Submit
</v-btn>
</v-card-actions>
</v-card>
</v-container>
</template>
解决方案
推荐阅读
- sql - 使用 CASE 语句仅搜索 DateTime 格式的时间
- reactjs - 获取错误:除非刷新页面,否则无法加载资源 - React
- php - 在 shopify 结账时显示 Laravel 数据
- jenkins - 詹金斯管道中的预提交(工具),初始化并停止构建?
- typescript - 打字稿不会转译导入路径
- sql-server - PowerShell - 将文件名添加到要导入 SQL Server 的列列表中
- image - 如何输入正确的图像路径
- r - 通过 ID 和索引获取第一个值
- php - Laravel 8惯性将数据传递给AppLayout
- javascript - 在 Javascript 中制作函数的真实副本