简体   繁体   English

使用正则表达式angularjs验证文件路径

[英]Validate file path with regular expression angularjs

I need to check if my input is correct. 我需要检查我的输入是否正确。 It must look like Folder/game.dll Here is my code: 它必须看起来像Folder/game.dll这是我的代码:

<input type="text" name="addRelativePath" ng-model="addGameModel.RelativePath" class="form-control" required ng-pattern="validationRegex">

My angularJs: 我的angularJs:

 $scope.validationRegex = / (\w+[^.]\/)+\w+.dll /;

What is wrong? 怎么了? Nothing happend whem I submit my form and expression in input is incorrect. 我提交表单和输入中的表达不正确时,什么都没发生。

Are you checking form validy thorough the form controller property $valid? 您是否通过表单控制器属性$ valid检查表单有效性? It should be checked if not angular will submit the form 应该检查是否不成角度将提交表格

<form novalidate name="vm.form" ng-submit="vm.form.$valid && vm.submit()">
</form>

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

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