我需要一個幫助。我有一個輸入字段驗證,並且此字段只接受包含使用Angular.js模式的十進制值的數字。我在下面解釋我的代碼。不能允許使用Angular.js輸入字段內的十進制值
<div class="input-group bmargindiv1 col-md-12">
<span class="input-group-addon ndrftextwidth text-right" style="width:180px">
Unit Sale Price :
</span>
<div ng-class="{ 'myError': billdata.usp.$touched && billdata.usp.$invalid }">
<input type="text" name="usp" id="usp" class="form-control"
placeholder="Add Unit Sale Price"
ng-model="unit_sale_price"
ng-keypress="clearField('usp');"
ng-keyup="setLatestSalePrice();"
ng-pattern="/^(0|[1-9][0-9]*)$/">
<div style="clear:both;"></div>
</div>
</div>
<div class="help-block" ng-messages="billdata.usp.$error"
ng-if="billdata.usp.$touched || billdata.usp.$error.pattern">
<p ng-message="pattern" style="color:#F00;">
This field needs only number(e.g-0,1..9).
</p>
</div>
這裏我的問題是一樣的值小數也不會採取這種field.Here我只需要的字符也是不allowed.Please幫助我。
有你嘗試過輸入type =「number」? –