how to add validator to formgroup
this.myForm = this.formBuilder.group({
myControl1: this.defaultValue,
myControl2: this.defaultValue
});
debugger
this.myForm.setValidators(this.comparisonValidator())
}
public comparisonValidator() : ValidatorFn{
return (group: FormGroup): ValidationErrors => {
const control1 = group.controls['myControl1'];
const control2 = group.controls['myControl2'];
if (control1.value !== control2.value) {
control2.setErrors({notEquivalent: true});
} else {
control2.setErrors(null);
}
return;
};
Also in JavaScript:
- array map order by timestamp reactjs
- how to go to settings on next click in react native
- prevent multiple form submissions javascript
- how to convert a number to a string in javascript
- : not foundram Files/nodejs/npm: 3: : not foundram Files/nodejs/npm: 5:
- button inside popover not viible
- rest api with mongodb and nodejs
- string slicing javascript
- js replace all substrings
- javascript go to url
- javascript prevent context menu
- fetch multiple urls javascript
- js html
- jsonarray find
- how to use aes for encryption and decryption in json object in java with demo
- kendo datetime picket default timezone
- animejs reduce the speed
- lookup in mongodb array
- convert int to float in javascript
- event listener in react
- js split string
- javascript replace \n
- how to add seconds to time in js
- javascript read file lines into array vanilla