这是我的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();
}
});
});
答案 0 :(得分: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();
});
答案 1 :(得分:1)
我认为这就是你所需要的:
$(document).on("focusout", ".Rqty", function() {
alert($(this).val()); // do the validation here
});