1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

How to change or modify the input text string value before passing it to custom validation in...

Discussão em 'Angular' iniciado por kiran gudla, Julho 25, 2025.

  1. kiran gudla

    kiran gudla Guest

    this is my code for form initialization , i want to convert reading value to number everytime before it passes to validation


    this.meterForm = this.formBuilder.group({
    'reading': [newReading, this.getValidator(this.meter)],
    'date': [this.date],
    'time': [this.time],
    'comments': [comments]
    });

    public getValidator(aMeter: Meter): ValidatorFn {
    if (this.meter.type === this.generalInfo.meterTypes.counter) {
    // I want to change the 'reading' input text field which is a string to number
    return Validators.compose([
    Validators.required,
    WorkorderValidators.maxLength(18),
    WorkorderValidators.max(this.meter.maxValue),
    WorkorderValidators.min(this.meter.minValue),
    WorkorderValidators.increment(0.0001, this.meter.minValue),
    WorkorderValidators.precision(3)
    ]);
    } else {
    return Validators.compose([
    Validators.required,
    this.meterReadingValueValidation(18, 3)
    ]);
    }
    }

    Continue reading...

Compartilhe esta Página