【问题标题】:differentiate between two input boxes max and min value区分两个输入框的最大值和最小值
【发布时间】:2015-10-20 07:31:24
【问题描述】:
<section class="col col-4">
    <label>Min Stock Level</label>
    <label class="input">
        <input type="text" name="minStock" min="0" ng-model="item.MinStockLevel" ng-pattern="/^[0-9]+(\.[0-9]{1,6})?$/" required />
        <span ng-show="myForm.minStock.$dirty && myForm.minStock.$invalid">
            <span style="color:green" ng-show="myForm.minStock.$error.required">Price is Required</span>
            <span style="color: red" ng-show="myForm.minStock.$error.pattern">Not Valid</span>
         </span>
     </label>
 </section>

这是第一个输入最小值的文本框。

<section class="col col-4">
     <label>Max Stock Level</label>
     <label class="input">
         <input type="text" name="maxStock" ng-     model="item.MaxStockLevel" min=" {{ item.MinStockLevel + 1 }}" ng-pattern="/^[0-9]+(\.[0-9]{1,6})?$/" required />
          <span ng-show=" myform.maxstock.$dirty && myform.maxstock.$invalid">
              <span style="color:green" ng-show="myForm.maxStock.$error.required">Price is Required</span>
               <span style="color: red" ng-show="myForm.maxStock.$error.pattern">Not Valid</span>
           </span>    
     </label>
 </section>

它是第二个输入框。我想区分两个盒子的最小库存水平和最大库存水平值。用户可以输入大于最小值的最大值和小于最大值的最小值。如何验证?

【问题讨论】:

  • 那么,您到底希望实现什么?在输入框级别应用最小和最大条件?
  • 是的,我想在我的文本框或任何验证我的框的 ng-validation 上应用最小和最大条件
  • 不应该把input type="text"改成input type="number"吗?因为 min 和 max 不适用于输入类型的文本。它们对数字有效。

标签: angularjs


【解决方案1】:

似乎问题出在 input type="text" 上,应该是 input type="number",因为 min 和 max 适用于数字,而不是文本。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多