javascript - 使用带有文本框检查的 JQuery 更新表行,我需要检查文本框值

标签 javascript jquery asp.net-mvc jquery-ui

这是我的 JQuery,当单击按钮时,我将表行附加到具有文本框的表中,我需要在聚焦时检查该文本框值,请有人帮助我 friend

我的 html 代码 friend

       <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();
        }
      });
   });

最佳答案

我认为这就是您所需要的:

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

关于javascript - 使用带有文本框检查的 JQuery 更新表行,我需要检查文本框值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21086876/

相关文章:

c# - 如何在 ASP.NET MVC 中选择数据访问方法?

javascript - 在没有弹出窗口的情况下将 onClicked 处理程序添加到浏览器操作?

javascript - &lt;textarea&gt; 默认内容在 &lt;textarea&gt; 元素中添加 formControlName 时消失

php - "xmlResult.Result is undefined"错误

javascript - 在手机间隙中使用 Objective-C 原生自定义框架/代码

jquery - jquery-mobile 单选按钮中的数据图标

javascript - 写一个for循环来创建div

javascript - 如何使用 jquery 删除 br?

asp.net-mvc - 使用 Windows 身份验证和 OWIN 的 ASP.NET MVC5/AngularJS/Web API 应用程序

asp.net-mvc - 使用带有操作参数的 ASP.NET MVC 子 Controller ?