required 相关问题

必需是输入元素的HTML属性,强制提供输入。

如何处理 C# 中的“必需成员必须在对象初始化程序或属性构造函数中设置”错误

我有两个班级 - 州 - 校长班级和学区家属班级。 公共类状态 { 公共 int StateId { 获取;放; } 公共必需的字符串 StateName { get;放; } 公开

回答 1 投票 0

我想将必填字段符号(星号)的颜色更改为红色

我想将必填字段符号(星号)的颜色更改为红色。我正在使用 Mud-Blazor。我使用下面的代码尝试了它。这是我应用代码后的图像这是我正在使用的代码...

回答 1 投票 0

我的表单中有两个必填字段。我希望星号颜色应该是红色。目前它显示为黑色

我的表单中有两个必填字段。我希望星号颜色应为红色。目前它显示为黑色。我正在使用 Mudblazor。 我尝试了多种方式但没有得到输出。请让...

回答 1 投票 0

在 Angular 中动态更改选择字段的验证

我的 Angular 应用程序遇到问题,在提交表单后,我动态更改表单中选择字段的必需属性。 评估.component.html <...

回答 1 投票 0

`必需`属性和 EF Core

一年前,C#版本。 11、添加了所需的修饰符。因此,如果我们按要求标记属性,如下所示: 公开课点 { 公共要求 int X { get;放; } 公共要求 int Y { ge...

回答 0 投票 0

C# 解决警告编译“CS8618”的最佳方法是什么

如果我们像这样声明属性: 公开课猫 { 公共字符串名称{获取;放; } } 我们收到警告编译: CS8618 - 不可为空变量必须包含非空值 退出

回答 1 投票 0

为什么必需的属性在表单上不起作用?

我正在创建此表单,但是当我单击“创建任务”按钮时,所需的属性将被忽略。 我正在使用 innerHTML 和创建表单: 我正在创建此表单,但是当我单击“创建任务”按钮时,所需的属性将被忽略。 我正在使用innerHTML 创建表单,并且: <form id="task-form"> <label for="task-title">Title:</label> <input type="text" id="task-title" name="task-title" required> <label for="task-date">Due date:</label> <input type="date" id="task-date" name="task-date" required> <label for="task-description">Description:</label> <textarea name="task-description" id="task-description" required></textarea> <label for="checkbox">Add to a project?</label> <input type="checkbox" name="checkbox" id="checkbox"> <label for="task-priority">Priority:</label> <select name="task-priority" id="task-priority" required> <option value="Low">Low</option> <option value="Medium">Medium</option> <option value="High">High</option> </select> <button type="submit" id="create-task-btn">Create Task</button> </form>``` Also the console give me one warning saying: "Form submission canceled because the form is not connected" 因为您要动态添加创建侦听器所需的表单 // Create the form element and set its properties const form = document.createElement('form'); form.id = 'task-form'; // Create and append the form's content form.innerHTML = ` <label for="task-title">Title:</label> <input type="text" id="task-title" name="task-title" required> <label for="task-date">Due date:</label> <input type="date" id="task-date" name="task-date" required> <label for="task-description">Description:</label> <textarea name="task-description" id="task-description" required></textarea> <label for="checkbox">Add to a project?</label> <input type="checkbox" name="checkbox" id="checkbox"> <label for="task-priority">Priority:</label> <select name="task-priority" id="task-priority" required> <option value="Low">Low</option> <option value="Medium">Medium</option> <option value="High">High</option> </select> <button type="submit" id="create-task-btn">Create Task</button> `; // Append the form to the document const formContainer = document.getElementById('form-container'); formContainer.appendChild(form); // Add an event listener for form submission form.addEventListener('submit', function (event) { event.preventDefault(); // Prevent the default form submission behavior // Your form submission logic here }); <div id="form-container"></div>

回答 1 投票 0

有没有办法以角度有条件地设置所需的输入?

我想要实现的是仅在给出另一个输入时才需要组件/指令输入,例如: @Input() 名称!:字符串; @Input({ required: name!!}) surname!:string; 这是吗

回答 2 投票 0

根据需要通过 JavaScript 以模型驱动应用程序的形式定义可编辑网格内的字段

我想根据需要以与模型驱动应用程序相同的形式在多个可编辑网格中定义多个列。这背后的意义是,我们有 2 个不同的模型驱动应用程序,用于 2 个差异......

回答 2 投票 0

jsonschema 验证所需和/或有条件需要的属性

我需要验证一个始终具有 2 个属性的 json 对象: 类型 姓名 类型可以是“A”、“B”或“C”, 当类型为“A”时,属性“foo”也是必需的,并且没有其他属性可供使用...

回答 3 投票 0

playwright-test:测试是否需要输入

我需要输入登录表单: 我需要输入登录表单: <input autoComplete="email" defaultValue={email} disabled={state === 'submitting'} id="email" name="email" placeholder={t('user-authentication:email-placeholder')} required // HERE! type="email" /> 如何测试 Playwright 是否需要输入?我在 Chromium 中的本机浏览器警告是:“请填写此字段。” 有没有办法在 Playwright 中检查/断言此警告?或者另一种方法来测试是否需要输入? 我尝试使用 .fill('') 在输入中不写入任何内容,然后使用 page.keyboard.press('Enter') 按 Enter 键,但这些并没有导致出现警告。 如果消息是由浏览器显示的,而不是添加到 DOM 中的内容,那么您将很难直接在 Playwright 中测试它。 您可以检查 required 属性是否存在,并相信浏览器将显示警告。 await page.locator('input#email[required]') 还有一个约束验证您可以应用 如果该元素是必需的,并且该元素的值为空字符串,则该元素将遭受 valueMissing 的影响,并且该元素将匹配 :invalid 伪类。 await page.locator('input#email[required]:invalid') 可以但不建议测试。这是工作代码: import { expect, test} from '@playwright/test'; test('has error message presented', async ({ page }) => { await page.goto('https://q94u5.csb.app/'); const email = page.getByRole('textbox') const submit = page.getByRole('button', { name: 'Submit' }); await email.fill('x'); await submit.click(); const error = page.locator('input:invalid'); const validationMessage = await error.evaluate((element) => { const input = element as HTMLInputElement return input.validationMessage }) expect(validationMessage).toContain("Please include an '@' in the email address. 'x' is missing an '@'.") }); 在此处阅读有关内置验证的更多信息: https://www.w3.org/WAI/tutorials/forms/validation/

回答 2 投票 0

Angular Material 单选按钮组需要验证不起作用

我试图在用户单击“提交”时验证单选按钮组。文本字段和下拉列表在无效时显示红色,但单选按钮颜色在无效时不会更改。有什么建议吗?...

回答 2 投票 0

如何通过反射读取C# 11中所需的属性

在 C# 11 中,Microsoft 引入了字段和属性所需的属性作为类的成员。 我需要在反射中读取这个属性。我该怎么做? 例如,在 C1 类和 P1 属性中...

回答 1 投票 0

如何通过反射读取c# 11中的required属性

在 c# 11 中,微软确定字段和属性所需的属性作为类的成员。 我们需要在反射中读取这个属性。我该怎么办? 例如在 C1 类和 prope...

回答 1 投票 0

Mobile Safari 上的 HTML 表单“必需”属性不起作用

iPad 上的 Mobile Safari 应该兼容 HTML5,但似乎 required 属性不起作用。任何人都知道为什么,或者有一个不需要大量 JavaScript 的不错的解决方法......

回答 6 投票 0

尝试提交表单而不填写必填字段时如何获得提示? (不适用于 Firefox 移动版)

在 Firefox 移动版中提交表单而不填写必填字段时,我没有收到提示,显示缺少哪个字段。在 Windows 上的 Firefox 和 Android 上的 Chrome 中,我得到了一个工具...

回答 1 投票 0

需要 Visual Basic 下拉字段

在word中制作表格时,是否有代码可以使下拉列表成为必填字段。我有代码使自由文本字段成为必填字段,但没有下拉列表。以下是我的免费文本 子

回答 2 投票 0

Laravel 验证规则“必需”不起作用

返回[ '代码'=>'需要|最大:255', 'title' => 'required|max:255', 'start_at' => 'required|date_format:d/m/Y|before_or_equal:

回答 0 投票 0

Bitbucket 强制审查分支

我可以让用户成为每个 PR 到 master 分支的强制审查者吗? 例如: 我们有一个包含 dev、qa、master 分支的桶 我们有@user1,@user2 @user3 在外队 @user1 是一名建筑师...

回答 2 投票 0

编辑 WordPress 插件(想在 anthor php 文件中插入代码)

我想用php文件插入 特定行中的代码 在 anthor php 文件中 那可能吗?? 因为我想编辑插件功能,而且我不希望它在插件更新时改变

回答 1 投票 0

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.