2014-01-13 26 views
0

這是我的JQuery while按鈕單擊我追加表格中的錶行有文本框我需要檢查該文本框的值,同時請注意一些請幫助我的朋友更新表格行使用JQuery與文本框檢查,我需要檢查文本框的值

我的HTML代碼的朋友

 <html> 
     <head> 
     </head> 
     <body> 
     <table> 
      <tr>     
      <td>      
       <label id="RecFrom">Receied From</label><br /> 
       <%: Html.TextBox("RecFrom", null, new { @class = "onlyname", id="RFrom" })%> 
      </td> 
      <td> 
       <label id="RecDate" > Received Date </label><br />      
       <%: Html.TextBox("RecDate", null, new { @class = "date", id="Rdate", @readonly = "readonly" })%> 
      </td> 
      <td id="External"> 
       <%: Html.Label("External Referance") %> 
       <input type='text' id='Exref' name='ExternalReferance'> 
      </td>      
     </tr> 
     <tr id="Refdetails"> 
      <td> 
       <%: Html.Label("Referance Date") %> 
       <input type='text' id='RefDate' class='date' readonly='readonly'> 
      </td> 
      <td> 
       <%: Html.Label("Impact Of Payment") %> 
       <select id='Impact' name='Impact' class='dropdown'><option>NO</option><option>YES</option></select> 
      </td> 
      <td> 
       <%: Html.Label("Impact By Date") %> 
       <input type='text' id='impactdate' name='Impactdate' class='date' readonly='readonly'> 
      </td> 

     </tr> 
     <tr> 
      <td id="Amountdetails"> 
       <%: Html.Label("Impact By Amount") %> 
       <input type='text' id='Amount' name='ImpactAmount' class='Number'> 
      </td>    
     </table> 


    <table id="ProductRecipt"> 
    <tbody> 
    <tbody> 
    </table> 
     <input type="Submit" value="Next" id="btn"/> 
    </body> 
</html> 

我jQuery是

 $(document).ready(function() 
     $('#btn').click(function(){ 
      $('#ProductRecipt tbody').append("<tr><td class='code'>" + ItemCode + "<input type='hidden' name='ItemCode' value='" + ItemCode + "'/></td><td class='desc'>" + $('#Cat').val() + "<input type='hidden' name='ItemName' value='" + $('#Cat').val() + "'/></td><td class='qty'>" + $('#RFrom').val() + "<input type='hidden' name='ReceviedFrom' value='" + $('#RFrom').val() + "'/></td><td class='qty'>" + $('#Rdate').val() + "<input type='hidden' name='ReceviedDate' value='" + $('#Rdate').val() + "'/></td><td>" + result.Quantity + "<input type='hidden' class='TotalQuantity' value= '"+ result.Quantity +"'></td><td><input type='text' class='Rqty' name='ReceviedQuantity'></td><td><input type='text' name='Remarks' style='widht : 75px;'></td><td><input type='button' class='remove' value='remove'/></td></tr>"); 
      }); 
     $('#ProductRecipt tbody').on('focusout', '.Rqty', function() { 
     var qty = $(this).parent($('#ProductRecipt tbody .TotalQuantity').val()); 
     alert(qty); 
     var rqy = (this).val(); 
     alert(rqy); 
     if (qty > rqy) { 
      alert('Enter Minimum Quantity'); 
      return false; 
      $(this).focus(); 
     } 
     }); 
    }); 

回答

1

我認爲這是你所需要的:

$(document).on("focusout", ".Rqty", function() { 
    alert($(this).val()); // do the validation here 
}); 
+0

我有2文本框中的文本框正在獲取 – Dinesh

+0

專注於此的那個。 例如,如果您單擊文本框,然後單擊或按壓選項卡或以某種方式離開框,它將觸發事件。 $(this).val() - 表示文本框的值 –

+0

ok,然後如何比較同一行上的值而不是另一個文本框的值 – Dinesh

1

試試這個:

$(document.body).on('mouseout', '#ProductRecipt tbody .Rqty', function() { 
var qty = $(this).parent($('.TotalQuantity').val()); 
    alert(qty); 
    var rqy = ('.Rqty').val(); 
    if (qty > rqy) { 
     alert('Enter Minimum Quantity'); 
     return false; 
     $(this).focus(); 
}); 
+0

朋友document.body的意味着它可以讓所有的表體標籤可我右 – Dinesh

+0

我已經修改了selector.Please檢查現在 –

+0

它不是沃金它顯示警報消息[對象] [對象] – Dinesh