问题标签 [angular-custom-validators]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
angular-material - Angular 11 Custom ISBN Validator Reactive Forms
I'm doing a custom validation for an ISBN number, I already have the function that checks the number and works perfect giving me the response by console, but I need to do the custom validator to get the error in the view with the form control and in this step this error is showing in console when I write an ISBN number, It's like it checks the errors but it doesn't know when its right and it should take the null response as a right ISBN number, at least thats what I saw in some examples.
This is my typescript,
In my HTML I have some inputs that are included in the form:
angular - 自定义验证器不适用于 Angular 反应形式
我正在尝试创建一个自定义验证器来检查电话号码是否已经存在。我的代码如下:
验证函数
来自后端的用于验证电话号码的 API:
我的表单组
我的 HTML
我无法弄清楚问题发生在哪里。API 工作正常,但未显示错误消息。我真的很感激任何帮助。谢谢你!
angular - Angular 逻辑上的自定义验证器已成功实施,但未在我的网页 UI /HTML 上显示错误消息
所以我在我的 Angular 表单上做了一个自定义验证器,它的工作方式如下:
摘自我的 component.ts 文件:
MustBeUnique 是从带有代码的单独文件中导入的:
html代码摘录如下:
我在这里面临的问题是 MustBeUnique 文件中的逻辑在我使用 console.log() 跟踪它们时成功执行,但是我使用 setErrors 设置的错误消息没有显示在我的 HTML 上。
逻辑简单地说,用户为机场选择的到达和离开目的地不应该相同。所有其他验证器(内置)完美运行
angular - Angular 创建自定义响应式表单验证器
我创建了简单的 ValidatorFn 函数:
我正在尝试通过我的 formControl 使用它:
这些数组不是空的,因为它们的值已成功显示在我的 mat-chip-list 中:
问题是我的 formControl 总是错误的,但是当我将 formControlName 分配给 input 而不是 mat-chip-list 时,即使列表中没有项目,它也总是没有错误。
angular - 角度形式的从和到时间字段的自定义验证功能,这是一个可选字段
我正在处理有角度的表格并且有一个可选字段,它有从时间到时间,我必须做出条件,我只输入从时间或到时间,而不是两次,然后我应该看到错误消息,但它是可选的字段,所以我必须为此制作一个自定义验证器,我对如何为可选字段制作此自定义验证功能感到困惑。因此,如果有人可以提供帮助,那就太好了。
这是我的 html 表单代码:
这是我的 ts 文件:
angular - Angular:循环依赖
为什么回来是未定义的currentdate
?this.currentdate.getTime()