<bdo id='isd3k'></bdo><ul id='isd3k'></ul>
    1. <small id='isd3k'></small><noframes id='isd3k'>

      <legend id='isd3k'><style id='isd3k'><dir id='isd3k'><q id='isd3k'></q></dir></style></legend>
    2. <tfoot id='isd3k'></tfoot>
      <i id='isd3k'><tr id='isd3k'><dt id='isd3k'><q id='isd3k'><span id='isd3k'><b id='isd3k'><form id='isd3k'><ins id='isd3k'></ins><ul id='isd3k'></ul><sub id='isd3k'></sub></form><legend id='isd3k'></legend><bdo id='isd3k'><pre id='isd3k'><center id='isd3k'></center></pre></bdo></b><th id='isd3k'></th></span></q></dt></tr></i><div id='isd3k'><tfoot id='isd3k'></tfoot><dl id='isd3k'><fieldset id='isd3k'></fieldset></dl></div>

      asp.net 验证文本框 - 至少一个文本框必须有数据

      asp.net validate textbox - at least one text box must have data in(asp.net 验证文本框 - 至少一个文本框必须有数据)
      <legend id='vUv1Z'><style id='vUv1Z'><dir id='vUv1Z'><q id='vUv1Z'></q></dir></style></legend>
        <tbody id='vUv1Z'></tbody>

      <i id='vUv1Z'><tr id='vUv1Z'><dt id='vUv1Z'><q id='vUv1Z'><span id='vUv1Z'><b id='vUv1Z'><form id='vUv1Z'><ins id='vUv1Z'></ins><ul id='vUv1Z'></ul><sub id='vUv1Z'></sub></form><legend id='vUv1Z'></legend><bdo id='vUv1Z'><pre id='vUv1Z'><center id='vUv1Z'></center></pre></bdo></b><th id='vUv1Z'></th></span></q></dt></tr></i><div id='vUv1Z'><tfoot id='vUv1Z'></tfoot><dl id='vUv1Z'><fieldset id='vUv1Z'></fieldset></dl></div>
        <bdo id='vUv1Z'></bdo><ul id='vUv1Z'></ul>

          • <small id='vUv1Z'></small><noframes id='vUv1Z'>

                <tfoot id='vUv1Z'></tfoot>
                本文介绍了asp.net 验证文本框 - 至少一个文本框必须有数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我有三个文本框,我想验证它们.至少一个文本框必须包含数据.

                I have three textboxes and I want to validate them. At least one textbox must contain data.

                我该怎么做?

                (文本框是家庭电话号码,工作电话号码,手机号码,我需要检查至少指定一种联系方式)

                (The textboxes are Home Phone No., Work Phone No., Mobile No. and I need to check at least one method of contact is specified)

                推荐答案

                使用自定义验证器,无需循环浏览页面上的文本框,因为这种方法可以获取页面上的所有文本框.ClientValidationFunction 中指定的 JavaScript 函数将为每个带有关联验证器的文本框调用.

                Use a Custom Validator, there is no need to cycle through the text boxes on the page as this approach gets ALL of the text boxes on the page. The JavaScript function specified in the ClientValidationFunction will be called for each text box with a validator associated with it.

                <asp:TextBox ID="txtHomePhone" runat="server"></asp:TextBox>
                <asp:CustomValidator ID="cvHomePhone" runat="server" ErrorMessage="*" ClientValidationFunction="Validate" ControlToValidate="txtHomePhone"  ValidateEmptyText="true"></asp:CustomValidator>
                
                
                <asp:TextBox ID="txtWorkPhone" runat="server"></asp:TextBox>
                <asp:CustomValidator ID="cvWorkPhone" runat="server" ErrorMessage="*" ClientValidationFunction="Validate" ControlToValidate="txtWorkPhone"  ValidateEmptyText="true"></asp:CustomValidator>
                
                
                <asp:TextBox ID="txtMobilePhone" runat="server"></asp:TextBox>
                <asp:CustomValidator ID="cvMobilePhone" runat="server" ErrorMessage="*" ClientValidationFunction="Validate" ControlToValidate="txtMobilePhone"  ValidateEmptyText="true"></asp:CustomValidator>
                
                
                <script language="javascript">
                function Validate(sender, args)
                {
                    args.IsValid = false;
                    if(args.Value != "")
                    {
                        args.IsValid = true;
                    }
                }
                </script>
                

                这篇关于asp.net 验证文本框 - 至少一个文本框必须有数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                How to keep the Text of a Read only TextBox after PostBack()?(PostBack()之后如何保留只读文本框的文本?)
                Winforms Textbox - Using Ctrl-Backspace to Delete Whole Word(Winforms 文本框 - 使用 Ctrl-Backspace 删除整个单词)
                Multi-color TextBox C#(多色文本框 C#)
                How can i set the caret position to a specific index in passwordbox in WPF(如何将插入符号位置设置为 WPF 密码框中的特定索引)
                C# Numeric Only TextBox Control(C# 纯数字文本框控件)
                Unicode characters not showing in System.Windows.Forms.TextBox(System.Windows.Forms.TextBox 中未显示 Unicode 字符)
                • <bdo id='7xFO0'></bdo><ul id='7xFO0'></ul>
                  • <legend id='7xFO0'><style id='7xFO0'><dir id='7xFO0'><q id='7xFO0'></q></dir></style></legend>

                    <small id='7xFO0'></small><noframes id='7xFO0'>

                          <tbody id='7xFO0'></tbody>
                        <i id='7xFO0'><tr id='7xFO0'><dt id='7xFO0'><q id='7xFO0'><span id='7xFO0'><b id='7xFO0'><form id='7xFO0'><ins id='7xFO0'></ins><ul id='7xFO0'></ul><sub id='7xFO0'></sub></form><legend id='7xFO0'></legend><bdo id='7xFO0'><pre id='7xFO0'><center id='7xFO0'></center></pre></bdo></b><th id='7xFO0'></th></span></q></dt></tr></i><div id='7xFO0'><tfoot id='7xFO0'></tfoot><dl id='7xFO0'><fieldset id='7xFO0'></fieldset></dl></div>

                        • <tfoot id='7xFO0'></tfoot>