When working with TypeScript, I am attempting to validate an input field to only accept binary numbers (0 and 1).
Here is my HTML:
<div>
<input type="text" (keypress) = "binaryValidate($event)">
</div>
And here is my TypeScript code:
binaryValidate(evt: number) {
if (evt === 1 ) {
return true;
} else if (evt === 0) {
return true;
} else {
return false;
}
}
However, for some reason, it always returns false.