Php 如何在文本框中验证angularjs?
为什么我的名字文本框中的ng模式允许使用特殊字符? 这是视图文件:Php 如何在文本框中验证angularjs?,php,angularjs,ng-pattern,Php,Angularjs,Ng Pattern,为什么我的名字文本框中的ng模式允许使用特殊字符? 这是视图文件: <div ng-repeat="s in config.students"> <div class="form-group"> <label class="control-label col-lg-2"></label> <div class="col-lg-5"> <input type="text
<div ng-repeat="s in config.students">
<div class="form-group">
<label class="control-label col-lg-2"></label>
<div class="col-lg-5">
<input type="text" class="form-control" name="students[]" ng-trim="false" ng-model="class.students[$index]" required ng-pattern="/^[a-zA-Z]*$/">
</div>
<div class="col-md-5">
<button class="btn btn-danger btn-sm" ng-click="removeStudent($index)" type="button">X</button>
</div>
</div>
</div>
<div class="form-group">
<label class="control-label col-lg-2"></label>
<div class="col-lg-4">
<button type="submit" class="btn btn-primary btn-grad btn-rect">Submit</button>
<a href ="<?php echo base_url();?>index.php/main/index" class="btn btn-default btn-grad btn-rect">Cancel</a>
</div>
</div>
X
提交
ng模式
本身不会阻止用户在文本框中输入特定文本。如果要这样做,需要在
上使用自定义属性指令
ng模式
旨在与AngularJS的表单验证结合使用,您可以使用它隐藏/显示验证消息,并在表单提交之前验证表单。ng模式
本身不会阻止用户将特定文本输入文本框。如果要这样做,需要在
上使用自定义属性指令
ng模式
旨在与AngularJS的表单验证结合使用,您可以使用它隐藏/显示验证消息,并在表单提交之前验证表单。AngularJS表单验证要求表单中每个输入字段的名称唯一
但是在您的例子中,ng repeat中的所有输入字段都使用相同的名称。
所以,更改您的输入,使用$index为每个迭代中的输入添加唯一的名称
<input type="text" class="form-control" name="students{{$index}}" ng-trim="false" ng-model="class.students[$index]" required ng-pattern="/^[a-zA-Z]*$/">
以下是。AngularJS表单验证要求表单中每个输入字段具有唯一名称 但是在您的例子中,ng repeat中的所有输入字段都使用相同的名称。 所以,更改您的输入,使用$index为每个迭代中的输入添加唯一的名称
<input type="text" class="form-control" name="students{{$index}}" ng-trim="false" ng-model="class.students[$index]" required ng-pattern="/^[a-zA-Z]*$/">
以下是。您使用的angularJS的哪个版本?我的angularJS版本是1.5.0您使用的angularJS的哪个版本?我的angularJS版本是1.5.0