I have a Javascript function that checks if the datatype of the use input is same as that expected by the control e.g. if a character has been entered in an integer field expected in textbox control. The validation message is displayed correctly but the alert does not go away and the function seems to be going into an endless loop. Any help would be appreciated..
Function is as given below :
public ValidateControl(event: Event, dataType: string) {
let isValid = true;
let objControl = event.target as HTMLInputElement;
let elementId = objControl.id;
let ctrlValue = objControl.value;
if (ctrlValue.trim() != '') {
isValid = Common.ValidateDataType(ctrlValue, dataType);
if (!isValid) {
document.getElementById(elementId).focus();
alert("Check your entry in '" + dataType + "' data type column");
}
}
}
<div *ngIf="head.ControlType == 'TextBox'">
<input (blur)="ValidateControl($event, head.DataType)" />