2016-12-14 123 views
0

提交我有這個登錄表單:按回車鍵

<div class="form col-md-12 center-block"> 
     <br /> 
     <div class="form-group"> 
     <input autocomplete="off" (keyup.enter)="focusElement(psw, $event)" autofocus type="text" class="form-control input-lg" [(ngModel)]="model.username" placeholder="Username" name="username"> 
     </div> 
     <div class="form-group"> 
     <input autocomplete="off" #psw (keyup.enter)="focusElement(btn, $event)" type="password" class="form-control input-lg" [(ngModel)]="model.password" placeholder="Password" name="password"> 
     </div> 
     <div class="form-group"> 
     <button #btn (click)="login()" class="btn btn-primary btn-lg btn-block" [disabled]="loading" type="text">login</button> 
     <img *ngIf="loading" src="data:image/gif> 
     </div> 
     <div *ngIf="error" class="alert alert-danger"> 
     {{error}} 
     </div> 
    </div> 

當加載頁面時,我注重的用戶名輸入設定,然後我點擊進入,和我的工作重點轉到密碼,然後我必須單擊只輸入兩次,並在我登錄下一頁後。

而我會點擊輸入像這樣:用戶名後,當我寫密碼點擊一次輸入,並登錄按鈕提交。

+1

刪除您的(keyup.enter):字段之間導航的標準方法是使用TAB。使用類型「提交」而不是「文本」來讓按鈕成爲一個按鈕。在ngSubmit中使用

元素進行登錄。總之...使用標準的HTML。 –

+0

@JBNizet這可能會修復它 – J0N3X

+0

@JB Nizet我使用輸入轉到下一個輸入標籤 – eduard

回答

0

你可以使用(提交)表單元素的方法嗎?

+0

對不起,但我不明白是什麼意思「使用提交方法」 – eduard