简体   繁体   中英

Angualr2 Validation Number Regex

Hi i dont konow how valid number in my input Code is here

angular2 Validator Error: Template parse errors:(…)

im add this

<form name="authForm" novalidate="" ng-submit="login()" class="md-padding" >
        <div layout="column" class="layout-column">
            <div class="md-form" style="margin-bottom: 64px; margin-top: 20px" [class.invalid]="user.number && user.number.length < 15">
                <input class="mdl-textfield__input" [(ngModel)]="user.number" name="number" type="tel" (focus)="focus()" (blur)="focusOut()" [textMask]="{mask: mask}" id="emailInput" required>
                <label class="mdl-textfield__label" [class.active]="user.number != null" for="emailInput">Numer telefonu</label>
            </div>
            <div class="md-form" style="margin-bottom: 44px" [class.invalid]="user.password <= null">
                <input class="mdl-textfield__input" [(ngModel)]="user.password" name="password" (focus)="focusPass()" (blur)="focusOutPass()" type="password" id="passInput" required>
                <label class="mdl-textfield__label" [class.active]="user.password != null" for="emailInput">Hasło</label>
            </div>
            <a class="router" routerLink="/panel"><button (click)="logIn($event)" class="md-raised md-accent md-button md-ink-ripple " [class.active]="user.password != null && user.number != null" style="width: 320px" type="submit" aria-label="Zaloguj się"><span>Zaloguj się</span></button></a>
        </div>
    </form>

im must do function? i have problem with regex, in input im see '_' character and user.number.length counts it as a sign

It might be confusing

number

property of your model with typescript number type. Did you try changing number with mobile_number or some other name?

TypeScript Basic Types

I normally use 'digit' that comes with this package. It is also good when you want to build with --aot

Angular2-Validation

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM