i’m doing this function that take the form control and loop inside it to see which element not valid
(formControlName = id ) i named all the ids with the same name of formControlName:
isSlideValid(formName) : boolean{
if(formName.invalid){
this.showErrorInputMessage = true;
let target;
let id;
for (let i in formName.controls) {
if (formName.controls[i].invalid) {
target = formName.controls[i];
id = i;
break;
}
}
if (target) {
let yOffset = document.getElementById(id).offsetTop;
this.content.scrollTo(0, yOffset, 4000)
}
return false;
}
return true;
}
it works fine , but it scroll always to the top not to the specific element.
Kindly note that the form is inside a ion-slide