【发布时间】:2018-01-27 02:04:57
【问题描述】:
当我尝试从带有角度验证的文件类型输入上传图像时,它显示错误并且不会通过
<input type="file" name="displaypic" ng-model="displaypic" ng-pattern="/\.(jpe?g|png|gif|bmp)$/i" ng-required="true" />
<span ng-show="SignupForm.displaypic.$error.pattern">* Must be an Image</span>
使用 css 作为
input.ng-invalid.ng-touched{border: 2px solid red;}
它没有显示$error.pattern的错误,只是获取无效文件的css并且没有让表单提交
【问题讨论】:
-
input[type=file]不是 play well withngModel。 -
我现在该怎么办?
-
您可以尝试使用this answer中提到的
directive或this question中的其他一些。
标签: javascript html css angularjs validation