无论如何在点击按钮或链接时禁用形式验证?

时间:2016-05-23 15:26:59

标签: javascript angularjs validation angular-formly

我遇到了角度形式验证的问题,我有一个自动聚焦的密码输入并且有形式验证:

validators: {
    required: {
        expression: validations.required,
        message: translate.get('global.requiredField')
    },
    loginFailed: {
        expression: validations.serverValidationOnlyMessage,
        message: translate.get('signin.passwordSoftLock')
    }
},

validations.required函数是:

    return {
        required: function($viewValue) {
            if (!$viewValue) {
                return false;
            }
            return true;
        },

我有一个位于此输入正下方的“ForgotPassword”链接,不幸的是,当我点击该链接时,它没有注册,因为验证消息将链接向下推,这导致第一个链接“未命中”单击。第二次点击成功。

            {
                key: 'password',
                name: 'password',
                type: 'fieldPasswordWithShowToggle',
                templateOptions: {
                    label: translate.get('global.passwordLabel'),
                    labelSrOnly: true,
                    placeholder: translate.get('global.passwordPlaceholder'),
                    toggleText: {
                        show: translate.get('userInformation.showPasswordLabel'),
                        hide: translate.get('userInformation.hidePasswordLabel')
                    },
                    actionLinks: [{
                        text: translate.get('signin.forgotPasswordLabel'),
                        onClick: function() {
                            flowstack.use('forgotpassword').next();
                        }
                    }],
                    focus: formParameters.usernameIsKnown
                },

actionLink的HTML:

<formly-transclude></formly-transclude>
<div class="clearfix">
    <div class="pull-right">
        <button type="button"
            style="position:absolute;"
            class="btn btn-xs btn-link"
            ng-repeat="link in to.actionLinks"
            ng-click="link.onClick()">
            {{link.text}}
        </button>
    </div>
</div>

0 个答案:

没有答案