Home > Software design >  Angular Forms, invalidate a form if a p-select is unchanged with the original value
Angular Forms, invalidate a form if a p-select is unchanged with the original value

Time:05-24

my requirement is to disable the submit button until user changes any of the form control, the issue is the input fields which is a required field is easily handled, however the other control is a select control, and there are three options, based on settings, any of the three options is selected, if the user doesn't change the option in this select field then the submit button should remain disabled. is there any inbuilt validator that can assist for this? or if not any custom validator? I have tried few validators but it didn't work out

CodePudding user response:

Adding Validators.required to your select control should be sufficient

CodePudding user response:

you can use Form.valueChanges.subscribe(res=>{//your code here to enable and disable the submit button}) in reactive forms

this will help you to watch any change in the form

  • Related