我需要一个帮助。我有一个输入字段验证,并且此字段只接受包含使用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”? –