Horje
change the focus to next in angular forms Code Example
change the focus to next in angular forms
import { Directive, ElementRef, HostListener, Input } from '@angular/core';

@Directive({
selector: '[moveNextByMaxLength]'
})
export class MoveNextByMaxLengthDirective {

constructor(private _el: ElementRef) { }

@HostListener('keyup', ['$event']) onKeyDown(e: any) {
    if (e.srcElement.maxLength === e.srcElement.value.length) {

        e.preventDefault();

        let nextControl: any = e.srcElement.nextElementSibling;
       // Searching for next similar control to set it focus
        while (true)
        {
            if (nextControl)
            {
                if (nextControl.type === e.srcElement.type)
                {
                    nextControl.focus();
                    return;
                }
                else
                {
                    nextControl = nextControl.nextElementSibling;
                }
            }
            else
            {
                return;
            }
        }
    }
}

}




Javascript

Related
jquery direct window print pdf Code Example jquery direct window print pdf Code Example
javascript detect time on page Code Example javascript detect time on page Code Example
define conastant js Code Example define conastant js Code Example
Type '{}' is missing the following properties from type 'RouteComponentProps<{}, StaticContext, unknown>': history, location, match Code Example Type '{}' is missing the following properties from type 'RouteComponentProps<{}, StaticContext, unknown>': history, location, match Code Example
js invoke function Code Example js invoke function Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
7