如何验证隐藏字段

时间:2013-08-13 10:46:56

标签: jquery validation hidden-field

我正在使用dataTable(使用json绑定)列出我的已注册货币。 这是我如何调用将从数据库中获取数据的类:

<script type="text/javascript">

    function cancelByRedirect() {
        window.location = "PendingTransaction.aspx";
    }

    function btnSelect_Click(id) {
        jQuery('#<%= vID.ClientID %>').val(id);
    }


    jQuery(document).ready(function ($) {

        jQuery("#dialog").dialog({ autoOpen: false });

        jQuery("#indicator").hide();

        jQuery('#tblVirtualAccounts').dataTable({
            bProcessing: true,
            bServerSide: true,
            bFilter: false,
            sAjaxSource: '<%= ResolveUrl("~/Merchant/VirtualAccount/TableHelperCheque.aspx")%>',
            oLanguage: {
                "sZeroRecords": "No Records Found",
                "sProcessing": 'Fetching Records..<img height="32px" width="32px" src="<%= ResolveUrl("/images/velocity/wait-white.gif") %>">'
            },
            aoColumnDefs: [{
                sTitle: "", bSortable: false, fnRender: function (oObj) {
                    var retButtons = '<button type="button" class="btnSelect" id="btnSelect" name="btnSelect" onclick="btnSelect_Click(' + oObj.aData[0] + ')">Select</button>';

                    return retButtons;
                },
                sDefaultContent: '', aTargets: [0]
            },
                { sTitle: "Account Name", aTargets: [1], sDefaultContent: '' },
                { bVisible: false, aTargets: [2], sDefaultContent: '' },
                { sTitle: "Currency", aTargets: [3], sDefaultContent: '' },
                { bVisible: false, aTargets: [4], sDefaultContent: ''}],

            fnDrawCallback: function () {
                $('.btnSelect').click(function () {
                    $(this).parent().parent().parent().find("tr").css({ "background": "#FFFFFF" });
                    $(this).parent("td").parent("tr").css({ "background": "#EBEBEB" });
                });
            } //END fnDrawCallback

        }); //END datatable           

    });   //END document.ready

</script>

这是我的HTML:

<asp:HiddenField ID="vID" runat="server" Value="0" />

       <table id="tblVirtualAccounts" cellpadding="0" cellspacing="0" border="0" class="stdtable">                    
            <thead>
            </thead>
            <tbody>
            </tbody>
            <tfoot>
            </tfoot>

       </table>

       <p class="stdformbutton">
       <asp:Button CssClass="submit radius2" Text="Submit" runat="server" ID="btnSubmit" CommandName="Finish" OnCommand="btnApproveTransaction_OnCommand" />
       <button type="button" id="btncancel" onclick="cancelByRedirect()" class="radius2" runat="server">Cancel</button>
       </p>

现在,我的问题是: 我将如何验证隐藏的字段。当vID.value =“0”时,Errormsg将是:请选择一个帐户。当vID.value!=“0”时,交易将被保存。

0 个答案:

没有答案