Changing a form


#1

Hello!

I got a new problem, hope that someone would be able to help me :slight_smile:

I’m creating a form with FormBuilder. For now, I have this:

this.registerForm = this.formBuilder.group({
bank3: [’’],
bank4: [’’],
bank5: [’’],
})

Very simple form. So the thing that I would like is to able to modify it after its initialisation. For example, adding a validator to one of the components --> for example, I would like to know the command to transform
bank3: ['']
to
bank3: ['',Validators.required]
I was thinking to use:
this.registerForm.addControl
But I have no idea how to use it. Any idea?

Also, another question: I would like a validator to control the pattern. For example, I want to have an ion-input where the user can entry only upper case and/or number. I was thinking doing this:
Validators.pattern("(?=^.{0,}$)((?![.\n])|(?=.*[A-Z]))")
but as you can imagine, it is not working…