淘汰验证输入值不应该在foreach产品中

时间:2017-07-10 05:39:57

标签: validation knockout.js

我正在尝试验证输入(productName)值应该与foreach产品值唯一

<div class="form-group">
    <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> Product Name </label>
    <div class="col-sm-9">
       <input type="text" data-bind="value: productName" placeholder="Enter new Product name" class="col-xs-10 col-sm-5" />
   </div>

   <button class="btn btn-info" type="submit" style="border:1px solid #FFF;">
    <i class="ace-icon fa fa-check bigger-110"></i>
        <span data-bind="text: isCreate() ? 'New' : 'Update'"> </span>
   </button>
</div>

<table id="tblProduct" class="table table-striped table-bordered table-hover">
   <thead>
      <tr>
         <th>Product Name</th>
      </tr>
   </thead>

   <tbody data-bind='foreach: products'>
      <tr>
          <td data-bind="text: ProductsName"></td>
      </tr>
   </tbody>
</table>

任何人都可以解释一下如何做到这一点吗?

0 个答案:

没有答案