当我在输入数字字段中输入十进制数字时,我想显示一些错误消息。所有其他错误都在抛出,也想这样做。 请查看我的代码
<form name = "myForm">
<md-input-container md-is-error = "myForm.quantityUpdateCtrl.$invalid">
<label>Quantity To Be Updated</label>
<input type = "number"
name = "quantityUpdateCtrl"
ng-model = "quantityToBeChange"
ng-min = 1
ng-step="0"
ng-init = "quantityToBeChange=1"
ng-max = boxedItem.item_status.quantity_accepted
required>
<div role = "alert" ng-messages = "myForm.quantityUpdateCtrl.$error">
<div ng-message = "required">Quantity should not be empty</div>
<div ng-message = "min">Entered quantity should be greater than 0</div>
<div ng-message = "max">Entered quantity cannot be greater than Item quantity</div>
<div ng-message = "step">Entered Integer</div>
</div>
</md-input-container>
试过这个,不起作用。
<div ng-message = "step">Entered Integer</div>
请帮助我解决。
NOTE: I don't want to call a function and validate and then return.
得到答案。
在输入标签中添加了ng-pattern="/^[0-9]{1,}$/"
。
检查<div ng-message = "pattern">Please Enter An Integer</div>