Aspx:表单验证



我有一个带有一些div的表单,每个div都包含一些输入,比如一个文本框和一个组合框,其中一个需要填写,否则表单将无法提交。div可以看起来像下面的

<div id="div6" class="item" runat="server">
<div class="card-header card-header-divider mb-3">Sorgerecht</div>
<div class="card-body pt-2 pl-md-4 pr-md-4 pb-0">
<div id="div6_row1" class="row mb-2">
<div class="col-12 col-sm-7 col-md-6 col-lg-6 col-xl-5">
<dx:ASPxLabel runat="server" Text="Sorgerecht:" ID="div6_row1_lb1" Theme="Office365" ></dx:ASPxLabel>
</div>
<div class="col-12 col-sm-5 col-md-6 col-lg-6 col-xl-7">
<dx:ASPxComboBox ID="div6_row1_ctl1" ClientInstanceName="div6_row1_ctl1" NullText="Wählen Sie das Sorgerecht aus" runat="server" Culture="de-DE" Theme="Office365"  Width="100%" ValueField="myparentkey" TextField="fld_bezeichnung">
<ClientSideEvents ValueChanged="function(s,e){CheckSorgerecht(s);}" Init="function(s,e){CheckSorgerecht(s);}" />
</dx:ASPxComboBox>
</div>      
</div>
<!-- Adoptiveltern Herkunftsland -->
<div id="div6_row2" class="row mb-2 div6adoptiv">
<div class="col-12 col-sm-7 col-md-6 col-lg-6 col-xl-5">
<dx:ASPxLabel runat="server" Text="Adoptiveltern Herkunftsland Kind:" ID="div6_row2_lb1" Theme="Office365" ></dx:ASPxLabel>
</div>
<div class="col-12 col-sm-5 col-md-6 col-lg-6 col-xl-7 text-right text-lg-left">
<dx:ASPxTextBox ID="div6_row2_ctl1" ClientInstanceName="div6_row2_ctl1" runat="server" AllowCustomText="True" Culture="de-DE" NullText="Adoptiveltern Herkunftsland Kind" Width="100%" Theme="Office365"  ShowImageInEditBox="True" ></dx:ASPxTextBox>
</div> 
</div>
<!-- Sonstige -->
<div id="div6_row3" class="row mb-2 div6sonstige">
<div class="col-12 col-sm-7 col-md-6 col-lg-6 col-xl-5">
<dx:ASPxLabel runat="server" Text="Sonstige" ID="div6_row3_lb1" Theme="Office365" ></dx:ASPxLabel>
</div>
<div class="col-12 col-sm-5 col-md-6 col-lg-6 col-xl-7 text-right text-lg-left">
<dx:ASPxTextBox ID="div6_row3_ctl1" ClientInstanceName="div6_row3_ctl1" runat="server" AllowCustomText="True" Culture="de-DE" NullText="Sonstige" Width="100%" Theme="Office365"  ShowImageInEditBox="True"  ></dx:ASPxTextBox>
</div> 
</div>
</div>

你能给我提供最好的练习吗?

非常感谢!

使用RequiredFieldValidator控件。对于每个必需的输入字段,添加一个RequiredFieldValidator控件。

<asp:RequiredFieldValidator ID="rfvdiv6_row1_ctl1" 
runat="server" ControlToValidate ="div6_row1_ctl1"
ErrorMessage="Field required"> 
</asp:RequiredFieldValidator>

相关内容

  • 没有找到相关文章

最新更新