0
我想允許任何東西,包括無效電子郵件(不包括@,空,等等)angularjs NG-模式如預期
https://jsfiddle.net/pb45k5xa/2/
我使用的是不起作用:
ng-pattern="/.*?/"
但它不工作,直到你不輸入把一個*@*
(如[email protected]
)。
我該如何避免這種情況?
我想允許任何東西,包括無效電子郵件(不包括@,空,等等)angularjs NG-模式如預期
https://jsfiddle.net/pb45k5xa/2/
我使用的是不起作用:
ng-pattern="/.*?/"
但它不工作,直到你不輸入把一個*@*
(如[email protected]
)。
我該如何避免這種情況?
<input type="email" ng-pattern="/.*?/" ng-model="email" placeholder="Enter an email here">
這裏type="email"
自己執行驗證。如果您想允許用戶鍵入任何內容,只需使用不帶type="email"
或ng-pattern="/.*?/"
的常規輸入即可。
module.directive('ngRemoveEmailValidation', function(){
return {
require : 'ngModel',
link : function(scope, element, attrs, ngModel) {
ngModel.$validators["email"] = function() {
return true;
};
}
}
});
我使用這個指令爲「搭橋」的驗證
我不能刪除TYPE =「電子郵件」,因爲它是移動有用(電子郵件投入使用另一個鍵盤(包含「@」在主視圖中的字符,等等) – fj123x
我明白了,你應該編輯你的問題來補充說明,無論如何,我認爲你發佈的答案是正確的方法。 –