zoukankan      html  css  js  c++  java
  • JS+后台验证数据是否存在于数据库中

    <asp:TemplateField HeaderText="所屬年月">
                <ItemTemplate>
                            <asp:TextBox ID="txtDate" runat="server" Width="90%" CssClass="TextBox" MaxLength="5"
                                       Text='<%# Eval("Var_Date") %>' onblur="this.value=this.value.replace(/D/g,'');ChkVatInvoice(this,'vatDate');"></asp:TextBox>
                </ItemTemplate>
                <HeaderStyle Width="6%" />
    </asp:TemplateField>

    function ChkVatInvoice(obj, val) {

     var txtVal = "";
                var vatType = "";
                var vatDate = "";
                if (val == "txt") {
                    txtVal = $(obj).val();
                    vatType = $(obj).parent().prev().children().first().val();
                    vatDate = $(obj).parent().prev().prev().prev().prev().children().first().val();
                }
                else if (val == "select") {
                    txtVal = $(obj).parent().next().children().first().val();
                    vatType = obj.value;
                    vatDate = $(obj).parent().prev().prev().prev().children().first().val();
                }
                else {
                    txtVal = $(obj).parent().next().next().next().next().children().first().val();
                    vatType = $(obj).parent().next().next().next().children().first().val();
                    vatDate = $(obj).val();
                }

                if (txtVal != "") {
                    if (txtVal.length < 2) {
                        alert("<%= localize.UnifiedNo + localize.IsNotValid %>"); //统编格式无效。
                    }
                    else {
                        //格式代码
                        var char1 = txtVal.substr(0, 1);
                        var char2 = txtVal.substr(1, 1);

                        if (vatType == "21" || vatType == "23" || vatType == "25") {
                            //前两位必须是英文且要存在于发票字轨

                            if (char1.charCodeAt() >= 65 &&
                          char1.charCodeAt() <= 90 &&
                          char2.charCodeAt() >= 65 &&
                          char2.charCodeAt() <= 90) {

      //检测是否存在发票字轨
                                var xmlURL = "JsonData.ashx?t=IT&val=" + txtVal.substr(0, 2) + "&vatType=" + vatType + "&vatDate=" + vatDate;

                                $.get(xmlURL, {}, function(result) {
                                    if (result == "N") {
                                        alert("<%=localize.lblVatInvoice %>"" + txtVal.substr(0, 2) + ""<%= localize.IsNotExistsInInvoice%>"); //发票号码 不存在於发票字轨。
                                        if (val == "txt") {
                                            obj.value = '';
                                            obj.focus();
                                        }

    }

  • 相关阅读:
    [LeetCode] Meeting Rooms I & II
    [LeetCode] Graph Valid Tree
    [LeetCode] Palindrome Permutation I & II
    [LeetCode] Encode and Decode Strings
    [LeetCode] Paint Fence
    android 发送短信功能
    andrioid 分享到其它(短信,qq,微信等功能)
    android Dialog实例
    android开发之onCreate( )方法详解
    android edittext属性说明
  • 原文地址:https://www.cnblogs.com/Chinarain/p/3822087.html
Copyright © 2011-2022 走看看