NG-模式用于验证比 [英] ng-pattern for validating ratio
本文介绍了NG-模式用于验证比的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经给了文本输入框的模式审定
NG-模式=^(2 [0-3] | [01] [0-9]):(?[0-5] [0-9]) $
它不扔任何验证的按钮。
全面实施是在这里:
<表格名称=configurationForm>
< DIV CLASS =表单组>
<输入类型=文本级=表格控占位=输入比例(例如:3:1)NG-模式=^([0-9])([0-9])$ NG模型=configuration.stripRatioNAME =stripRatio要求/>
<跨度类=错误POP_UPNG秀=。configurationForm.stripRatio $ error.pattern>请输入唯一ratio..Eg:3:1< / SPAN>
< / DIV>
< /表及GT;
<configurationForm $无效按钮NG-禁用=>保存< /按钮>
解决方案
试用
NG-模式=/ ^([0-9] +):([0-9] +)$ /
或
NG-模式=/ ^(\\ d +)(\\ D +)$ /
您正在忘记把/
,也可以使用的 +
量词
I have given a pattern validation for input text box as
ng-pattern="^(2[0-3]|[01]?[0-9]):([0-5]?[0-9])$"
Its not throwing any validation for the buttons. Full implementation is here:
<form name="configurationForm">
<div class="form-group">
<input type="text" class="form-control" placeholder="Enter Ratio (Eg:3:1)" ng-pattern="^([0-9]):([0-9])$" ng-model="configuration.stripRatio" name="stripRatio" required />
<span class="error pop_up" ng-show="configurationForm.stripRatio.$error.pattern">Please enter only ratio..Eg:3:1</span>
</div>
</form>
<button ng-disabled="configurationForm.$invalid">Save</button>
解决方案
Try it
ng-pattern="/^([0-9]+):([0-9]+)$/"
OR
ng-pattern="/^(\d+):(\d+)$/"
Your are forget to put "/"
, and also use "+"
quantifier
这篇关于NG-模式用于验证比的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文