最近中文字幕高清中文字幕无,亚洲欧美高清一区二区三区,一本色道无码道dvd在线观看 ,一个人看的www免费高清中文字幕

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Angular2驗證器,它依賴于多個表單字段

Angular2驗證器,它依賴于多個表單字段

largeQ 2019-11-06 11:10:47
是否可以創(chuàng)建一個可以使用多個值來確定我的字段是否有效的驗證器?例如,如果客戶首選的聯(lián)系方式是通過電子郵件,則必須填寫電子郵件字段。謝謝。更新了示例代碼...    import {Component, View} from 'angular2/angular2';    import {FormBuilder, Validators, formDirectives, ControlGroup} from 'angular2/forms';    @Component({        selector: 'customer-basic',        viewInjector: [FormBuilder]    })    @View({        templateUrl: 'app/components/customerBasic/customerBasic.html',        directives: [formDirectives]    })    export class CustomerBasic {        customerForm: ControlGroup;        constructor(builder: FormBuilder) {            this.customerForm = builder.group({                firstname: [''],                lastname: [''],                validateZip: ['yes'],                zipcode: ['', this.zipCodeValidator]                 // I only want to validate using the function below if the validateZip control is set to 'yes'            });        }        zipCodeValidator(control) {            if (!control.value.match(/\d\d\d\d\d(-\d\d\d\d)?/)) {                return { invalidZipCode: true };            }        }    }
查看完整描述

3 回答

  • 3 回答
  • 0 關(guān)注
  • 793 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號