我如何...如何在ASP.NET中没有requiredfieldvalidator的空文本框控件的javascript验证中使用验证摘要? [英] How do I...How to use validation summary in javascript validation for empty textbox control without requiredfieldvalidator in ASP.NET ?

查看:44
本文介绍了我如何...如何在ASP.NET中没有requiredfieldvalidator的空文本框控件的javascript验证中使用验证摘要?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在ASP.NET中没有requiredfieldvalidator的空文本框控件的javascript验证中使用验证摘要??

表示我在提交按钮上设置OnClientClick =Javascript:return Validations()时,它显示单警报框验证,但我想在一个警报框中显示所有空盒子的摘要...如何可能请帮助我紧急.... thnxs提前



从下面的评论中复制的其他信息



How to use validation summary in javascript validation for empty textbox control without requiredfieldvalidator in ASP.NET ??
Means when I set a OnClientClick="Javascript:return Validations()" on submit button,It is showing Single alert box validation but i want to show all summary of empty box in one alert box...how it is possible Pls help me its urgent....thnxs in advance

additional information copied from comment below

<body>
<form id="form1"  runat="server">
<script type="text/javascript">
    
function Validations()
{
   var FullName,Address;
   if(FullName=document.getElementById("<%=txtFullName.ClientID%>"))
   {
      if((FullName.value.length == 0)||(FullName.value.length == ""))
      {           
         FullName.focus();
         alert("Please enter FullName");
         return false;
      }
   }
   if(Address=document.getElementById("<%=txtAddress.ClientID%>"))
   {
      if((Address.value.length == 0)||(Address.value.length == ""))
      {
         Address.focus();
         alert("Please enter Address");
         return false;
      }
   }

   <div id="Div1" style="display: block"  runat="server">
      <table width="100%" border="1">
         <tr>
            <td width="50%" style="vertical-align: top;">
               <fieldset>
                  <legend class="Heading">Declarant Details </legend>
                  <table width="100%" border="0">
                     <tr>
                        <td class="label" colspan="1" style="width: 109px">
                           <asp:Label runat="server" ID="FullName" Text="Full Name :">
                        </td>
                        <td colspan="3">
                           <asp:TextBox ID="txtFullName" runat="server">
                        </td>
                     </tr>
                     <tr>
                        <td class="label" colspan="1">
                           <asp:Label runat="server" ID="Address">
                              Address:
                        </td>
                        <td colspan="3">
                           <asp:TextBox ID="txtAddress" runat="server">
                        </td>
                     </tr>
                     <tr>
                  </table>
               </fieldset>
            </td>
         </tr>
      </table>
   </div>
   <div>
      <table>
         <tr>
            <td>
            <asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click" OnClientClick="javascript:return Validations();" />
            </td>
         </tr>
      </table>
   </div>
</form>
</body>

推荐答案

我只是使用javascript部分来显示验证摘要提示框。



I am just using the javascript part to show the validation summary in a alert box.

<script type="text/javascript">
        function Validations() {
            var FullName, Address, alertText = "";
            if (FullName = document.getElementById("<%=txtFullName.ClientID%>")) {
                if ((FullName.value.length == 0) || (FullName.value.length == "")) {
                    if (alertText == "") {
                        alertText = "Please enter FullName \n";
                    }
                    else {
                        alertText += "Please enter FullName \n";
                    }
                }
            }
            if (Address = document.getElementById("<%=txtAddress.ClientID%>")) {
                if ((Address.value.length == 0) || (Address.value.length == "")) {
                    if (alertText == "") {
                        alertText = "Please enter Address \n";
                    }
                    else {
                        alertText += "Please enter Address \n";
                    }
                }
            }
            if (alertText != "") {
                alert(alertText);
                return false
            }
        }
    </script>





希望上面的代码有帮助。



Hope the above code helps.


<script type="text/javascript">
        function Validations() {
            var FullName, Address, alertText = "";
            if (FullName = document.getElementById("<%=txtFullName.ClientID%>")) {
                if ((FullName.value.length == 0) || (FullName.value.length == "")) {
                    if (alertText == "") {
                        alertText = "Please enter FullName \n";
                    }
                    else {
                        alertText += "Please enter FullName \n";
                    }
                }
            }
            if (Address = document.getElementById("<%=txtAddress.ClientID%>")) {
                if ((Address.value.length == 0) || (Address.value.length == "")) {
                    if (alertText == "") {
                        alertText = "Please enter Address \n";
                    }
                    else {
                        alertText += "Please enter Address \n";
                    }
                }
            }
            if (alertText != "") {
                alert(alertText);
                return false
            }
        }
    </script>



希望上面的javascript帮助


Hope the above javascript helps


这篇关于我如何...如何在ASP.NET中没有requiredfieldvalidator的空文本框控件的javascript验证中使用验证摘要?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆