Trigger validation of all fields in Angular Form submit

后端 未结 13 1397
悲哀的现实
悲哀的现实 2020-12-08 01:45

I\'m using this method: http://plnkr.co/edit/A6gvyoXbBd2kfToPmiiA?p=preview to only validate fields on blur. This works fine, but I would also like to validate them (and thu

13条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-08 02:12

    I done something following to make it work.

    HEADER NAME *
    Header Name is required

    In your controller you can do;

    addHeader(form, header){
            let self = this;
            form.$submitted = true;
            ... 
        }
    

    You need some css as well;

    .label-color {
                color: $gray-color;
            }
    .has-error {
           .label-color {
                color: rgb(221, 25, 29);
            }
            .select2-choice.ui-select-match.select2-default {
                border-color: #e84e40;
            }
        }
    .validation-message {
           font-size: 0.875em;
        }
        .max-width {
            width: 100%;
            min-width: 100%;
        }
    

提交回复
热议问题