简体   繁体   English

AngularJS自定义验证不适用于表达式

[英]Angularjs custom validation is not working using expressions

I am using below code to validate my Quantity text box. 我正在使用下面的代码来验证我的数量文本框。 when i enter wrong number it's showing error message, but the form is submitting. 当我输入错误的数字时,它会显示错误消息,但表单正在提交。

<span ng-show="model.Item.Quantity - model.Quantity < 0">Entered Quantity cannot be greater than the item quantity.</span>

use the following way : 使用以下方式:

<form name="formName">
    <input type="number" min="0" max="{{itemQuantity}}" name="inputName" ng-model="propertyName" />
    <span ng-show="formName.inputName.$invalid">Error Message </span>
    <button type="submit" ng-disabled="formName.$invalid" value="submit" />
</form>

You can find more info here : https://docs.angularjs.org/api/ng/input/input[number] 您可以在这里找到更多信息: https : //docs.angularjs.org/api/ng/input/input[number]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM