HTML:
TS(Component type script):
<input type="text" (input)="onTextboxChangeValidate($event)">
TS(Component type script):
onTextboxChangeValidate(event: Event) {
var inputData = (<HTMLInputElement>event.target).value;
//replace more than one dot
var extractedFte = inputData.replace(/[^0-9.]/g, '').replace('.', '')
.replace(/\./g, '').replace('x', '.');
//Extract number Values
extractedFte = extractedFte.replace(/^(\d+)\d*$/, "$1");
//Reasign to same control
(<HTMLInputElement>event.target).value = extractedFte;
}
No comments:
Post a Comment