I am looking to automatically insert a colon (:
) after every 2 characters in my input field:
HTML
<input nz-input type="text" appLimitInput="textAndNumbers" name="mac"
formControlName="mac" (keydown.space)="$event.preventDefault();"
onDrag="return false;" onDrop="return false;" onPaste="return false;">
Desired outcome:
For example, if I input AB
, it should automatically become AB:
. Similarly, if I then type CD
,
it will be displayed as AB:CD
. If I decide to delete/erase the CD
, the colon should also be automatically removed.
So, if I enter AB:CD:EF:GH:IJ:KL
, the input field should format it accordingly.