簡體   English   中英

模式在 angular2 中不起作用

[英]pattern is not working in angular2

我正在通過模式屬性實現驗證,但它不起作用。

 <input type="text"  formControlName="mobile" name="mobile" pattern="[0-9]" /> 

將此模式用於手機號碼。

<input type="text" name="mobile" ng-pattern="/\d{10}/" />

或者你可以使用這個

Mobile Number :
<input type="text" class="form-control" ng-model="mobileNo" name="mobileNo" ng-pattern="regEx" />

JavaScript

$scope.regEx="/^[0-9]{10,10}$/;"

如果你想讓它與模式屬性一起工作,那么

<input type="text" pattern="[789][0-9]{9}">

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM