我是Angular的新手。我正在使用角4反應形式,並找出如何執行自定義驗證。以下是我的數字執行Angular中的日期和貨幣驗證(4)
function numberValidator(c: AbstractControl): { [key: string]: boolean } | null {
if (c.pristine) {
return null;
}
if (c.value.match(/.*[^0-9].*/)) {
return { 'numeric': true };
}
return null;
}
phoneControl: ['', [Validators.required, Validators.minLength(10), Validators.maxLength(10), numberValidator]],
我想了解如何執行貨幣(有或沒有兩位小數)和最重要的日期字段。
原諒我,如果這是在別處回答,但我無法找到任何樣品的角度(4)
感謝您的時間
你爲什麼不使用CurrencyPipe? https://angular.io/api/common/CurrencyPipe – Wandrille
感謝您的建議。糾正我,如果我錯了。貨幣管道是用於將顯示值轉換爲正確的?我正在尋找文本框條目的驗證。 – Vinod
myBad!你是對的! – Wandrille