custom-validators

angular 4 : custom validator not working

时光怂恿深爱的人放手 提交于 2019-12-08 06:40:47
问题 I pulled this example from angular official doc. I noticed that the custom validation is working with the reactive forms but it is not working with template-driven forms. Here is the plunker of the mentioned example the directive: export function forbiddenNameValidator(nameRe: RegExp): ValidatorFn { return (control: AbstractControl): {[key: string]: any} => { const forbidden = nameRe.test(control.value); return forbidden ? {'forbiddenName': {value: control.value}} : null; }; } @Directive({

ASP.NET validator to compare two date difference is not more than 12 months

独自空忆成欢 提交于 2019-12-07 13:13:28
问题 I have two TextBox controls for start date & end date input. I have to validate that end date is not greater than start date & the difference between start date & end date is not more than 12 months. 回答1: You will have to use a CustomValidator to do this. In your markyou, you will have something like this: <asp:TextBox ID="txbStartDate" runat="server" /> <asp:TextBox ID="txbEndDate" runat="server" /> <asp:CustomValidator OnServerValidate="ValidateDuration" ErrorMessage="Dates are too far

ASP.NET validator to compare two date difference is not more than 12 months

半腔热情 提交于 2019-12-06 03:14:24
I have two TextBox controls for start date & end date input. I have to validate that end date is not greater than start date & the difference between start date & end date is not more than 12 months. You will have to use a CustomValidator to do this. In your markyou, you will have something like this: <asp:TextBox ID="txbStartDate" runat="server" /> <asp:TextBox ID="txbEndDate" runat="server" /> <asp:CustomValidator OnServerValidate="ValidateDuration" ErrorMessage="Dates are too far apart" runat="server" /> And in your code behind, you define the validation handler: protected void

CustomValidator not working well

邮差的信 提交于 2019-12-05 19:02:27
问题 I have the following piece of asp: <asp:ValidationSummary ID="RegisterUserValidationSummary" runat="server" CssClass="failureNotification" ValidationGroup="RegisterUserValidationGroup"/> ... <asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserNameTB">Username:</asp:Label> <asp:TextBox ID="UserNameTB" runat="server" CssClass="textEntry"></asp:TextBox> <asp:RegularExpressionValidator ID="RegularExpressionValidator1" ControlToValidate="UserNameTB" ValidationExpression="[a-zA-Z]

custom unobtrusive date validators for dates

微笑、不失礼 提交于 2019-12-04 15:02:36
Maybe it's just the way my mind works, but I have a very hard time understanding how you're supposed to do custom unobtrusive validators. The C# part is easy enough, but the jqueryui adapters are where i get lost. I've been trying to make a validator that requires a date to be a certain amount of time in the past. I use this for age validation, to make sure someone has entered a date that is 18 years in the past. I finally decided to just make it a remote validator, that way the validation uses the same code both client and server side. Still, i'd be interested in the jquery to make this work.

Grails: Custom validator based on a previous value of the field

孤者浪人 提交于 2019-12-04 04:21:02
问题 I am trying to create a custom validator for variable 'amount' in my domain class, such that the new value should be greater than previous by 0.50. For example, lets say the previous value was 1.0, next time the value should be atleast: [previous value + 0.50] or more. Thanks in advance for the help 回答1: You can try reading domainEntity.getPersistentValue('amount') . EDIT: ... in custom validator, like: class Bid { Double amount ... static constraints = { amount(validator: { double a, Bid b -

Display custom validator error with mat-error

只谈情不闲聊 提交于 2019-12-03 02:27:32
问题 I come to you for talking about a problem with angular material. In fact, I think it's an issue, but I prefer looking for a misunterstanding first. The first thing about my problem is the context, i try to do a simple form containing two inputs : a password and its' confirmation. user-form.component.ts this.newUserForm = this.fb.group({ type: ['', Validators.required], firstname: ['', Validators.required], lastname: ['', Validators.required], login: ['', Validators.required],

How do I hook up javascript to my CustomValidator control in .Net

余生颓废 提交于 2019-12-02 18:03:36
问题 I have created a CustomValidator control public class MyValidator :CustomValidator, IScriptControl {} and also created the equivalent client script. The server validation works fine, however how do I hook up my client script? The rendered javascript looks like var MyValidator1 = document.all ? document.all["MyValidator1"] : document.getElementById("MyValidator1"); MyValidator1.controltovalidate = "MyField"; MyValidator1.errormessage = "error"; MyValidator1.evaluationfunction =

Display custom validator error with mat-error

↘锁芯ラ 提交于 2019-12-02 17:33:23
I come to you for talking about a problem with angular material. In fact, I think it's an issue, but I prefer looking for a misunterstanding first. The first thing about my problem is the context, i try to do a simple form containing two inputs : a password and its' confirmation. user-form.component.ts this.newUserForm = this.fb.group({ type: ['', Validators.required], firstname: ['', Validators.required], lastname: ['', Validators.required], login: ['', Validators.required], matchingPasswordsForm: this.fb.group( { password1: ['', Validators.required], password2: ['', Validators.required], },

Why The error message for custom validator is not shown in message box?

蹲街弑〆低调 提交于 2019-12-02 08:53:19
问题 I have tried in many way but the error message for custom validator is not shown in validation summary but it(ValidationSummary) shows error message for every other type of validator. <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Expt_Custom Validator.aspx.cs" Inherits="Expt_Custom_Validator" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server">