Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jsp Angularjs:为文本框指定最小值_Jsp_Angularjs_Angularjs Directive - Fatal编程技术网

Jsp Angularjs:为文本框指定最小值

Jsp Angularjs:为文本框指定最小值,jsp,angularjs,angularjs-directive,Jsp,Angularjs,Angularjs Directive,我是angularjs的新手,我的要求是文本框的最小值应为10,如果用户输入的值小于10,则只要他关注另一个文本框(此处为文本框名称),该值应再次更改为10。我已经试过了,但想不出更多,请帮助,对不起,错误的英语和接受标准: <div ng-app=""><form name="myForm" ng-controller="Ctrl">Number: <input type="text" name="input" ng-model="value"

我是angularjs的新手,我的要求是文本框的最小值应为10,如果用户输入的值小于10,则只要他关注另一个文本框(此处为文本框名称),该值应再次更改为10。我已经试过了,但想不出更多,请帮助,对不起,错误的英语和接受标准:

<div ng-app=""><form name="myForm" ng-controller="Ctrl">Number: <input type="text" name="input" ng-model="value"
               min="10" max="500" required> Name: <input type="text" name="name" ng-model=""
               required>

<span class="error" ng-show="myForm.input.$error.required">
  Required!</span>
<span class="error" ng-show="myForm.input.$error.number">
  Not valid number!</span>

您需要使用ng change指令。有点像跟踪

<input type="text" name="name" ng-model="" ng-change="update()"  required>


>P>而不是重置该值,您应该考虑使用一个简单的验证错误消息,它由它自己的处理MI/MAX值的属性定义。p> 否则,一旦文本字段在未经通知的情况下开始重置值,用户就会认为文本字段有错误/错误。

update()是javaScript方法,在该方法中,如果值小于还原值10,您将检查该值
<input type="text" name="name" ng-model="" ng-change="update()"  required>