实现按回车键登录

1.css

.loginContainer  {
  1. width700px;
  2. heightauto;
  3. border-radius22px;
  4. marginauto auto;
  5. backgroundrgba(255,255,255,1)url(../images/login_title.png) no-repeat left top /100% 106px;
  6. padding131px 0 25px 0;
  7. box-sizingborder-box;
  8. positionabsolute;
  9. left0;
  10. right0;
  11. top50%;
  12. transformtranslateY(-50%);

2.js $('body').keydown(function (e) {

          console.log(e);
          if (e.target.offsetParent.className === 'loginContainer') {
              if (e.which === 13) {
                  $scope.register($scope.registerObj);
              }
          }

      });

3.html

<div class="login" ng-controller="registerCtrl">
  <div class="loginContainer">
    <span ng-show="loginerror != 0" class="yzCodeTip">{{loginerrorInfo | translate}}</span>
    <span ng-show="limitAuth" class="yzCodeTip">{{loginerrorInfo | translate}}</span>
    <div class="loginTitleWord"></div>
    <ul class="loginInner">
      <li class="loginPadd">
        <input class="login_user" type="text" placeholder="{{'login-user' | translate}}" ng-model="registerObj.username">
      </li>
      <li class="loginYz">
        <input type="text" placeholder="{{'login-verification' | translate}}" ng-model="registerObj.verifyCode" class="login_yzcode" maxLength="4">
        <div ng-click="resetCode()" class="getYz {{regObj.isClick?'getCode':''}}">
          获取验证码 <span ng-show="regObj.isClick">{{(regObj.time)}}s</span>
        </div>
      </li>
      <li class="loginPadd">
        <input class="login_pass" type="password" placeholder="{{'login-psd' | translate}}" ng-model="registerObj.password" minlength="6" maxlength="20">
      </li>
      <li class="loginPadd">
        <input class="login_confirmPwd" type="password" placeholder="{{'login-psd' | translate}}" ng-model="registerObj.confirmPwd" minlength="6" maxlength="20">
      </li>
      <li class="loginIn"><span ng-click="register(registerObj)">下一步</span>
      </li>
      <li class="loginIn"><a href="#" ui-sref="login()">已有账号,去登录&lg;&lg;</a></li>
    </ul>
  </div>
</div>

猜你喜欢

转载自blog.csdn.net/web_cgh/article/details/80896688