|
[Html]
<input ej-maskedit id="mask" name="mecode" [(ngModel)]="newContactMethod.phoneNumber" maskFormat='(999) 999-99999' (focusIn)="moveCursor(maskedit)" />
[Script]
moveCursor(){
var maskObj= $("#mask").ejMaskEdit("instance");
var maskInput = maskObj._textbox;
setTimeout(function(){
maskInput.setSelectionRange(0,0 )
});
} |
|
[Html]
<button type="button" (click)="moveCursor(maskedit)">Move Cursor</button>
//mask is a component instance of MaskEdit Component
<input #mask ej-maskedit name="mecode" [(ngModel)]="newContactMethod.phoneNumber" maskFormat='9 9 9 9 9' (focusIn)="moveCursor(maskedit)" />
[Typescript]
export class MaskComponent {
public newContactMethod: any;
@ViewChild('mask') maskedit: EJComponents<any, any>;
constructor() {
this.newContactMethod = { phoneNumber : "" }
}
moveCursor(medit):void {
if (!this.maskedit.widget.model.value) {
setTimeout(() => {
this.maskedit.widget._textbox.focus();
this.maskedit.widget._textbox.setSelectionRange(0, 0);
});
}
};
} |