不会检查ValidationExpression是否为空

时间:2015-03-05 17:59:22

标签: c# validation

如果我在页面上没有任何内容,只需单击“提交”,然后将其直接发送到数据库中,而不显示任何内容。

如果我写了一些内容然后再删除它也会发生这种情况,因此它不会向我发送消息。

<div class="col-lg-6">
        <label for="exampleInputEmail-4">
           Mobil nr
              <asp:RequiredFieldValidator
                 ID="RequiredFieldValidator1"
                 runat="server"
                 ErrorMessage=" - Husk Telefon nr"
                 ControlToValidate="TextBoxTelefon"
                 Font-Bold="True"
                 SetFocusOnError="True"
                  ValidationGroup="Pakke"
                 CssClass="errorOrdblindtest"></asp:RequiredFieldValidator>
           <asp:RegularExpressionValidator
              ID="RegularExpressionValidator1"
              runat="server"
              ErrorMessage=" - Dit telefonnr"
              ValidationExpression="^[0-9]{8}$"
              ControlToValidate="TextBoxTelefon"
              Font-Bold="True"
              CssClass="errorOrdblindtest"
               ValidationGroup="Pakke"></asp:RegularExpressionValidator>
        </label>
        <asp:TextBox ID="TextBoxTelefon" MaxLength="8" CssClass="form-control" runat="server" TextMode="Phone" ValidationGroup="Pakke"></asp:TextBox>
     </div>
     <div class="col-lg-6">
        <label for="exampleInputPhone-4">
           Adresse
              <asp:RequiredFieldValidator
                 ID="RequiredFieldValidator2"
                 runat="server"
                 ErrorMessage=" - Husk Adresse"
                 ControlToValidate="TextBoxAdresse"
                 Font-Bold="True"
                 SetFocusOnError="True"
                  ValidationGroup="Pakke"
                 CssClass="errorOrdblindtest"></asp:RequiredFieldValidator>
           <asp:RegularExpressionValidator
              ID="RegularExpressionValidator2"
              runat="server"
              ErrorMessage=" - Din Adresse"
              ValidationExpression="^[a-zA-Z0-9]{3, 60}$"
              ControlToValidate="TextBoxAdresse"
              Font-Bold="True"
              CssClass="errorOrdblindtest"
               ValidationGroup="Pakke"></asp:RegularExpressionValidator>
        </label>
        <asp:TextBox ID="TextBoxAdresse" MaxLength="60" CssClass="form-control" runat="server"></asp:TextBox>
     </div>
     <div class="col-lg-3">
        <label for="exampleInputCompanyname-4">
           Byen
              <asp:RequiredFieldValidator
                 ID="RequiredFieldValidator3"
                 runat="server"
                 ErrorMessage=" - Husk Byen"
                 ControlToValidate="TextBoxByen"
                 Font-Bold="True"
                 SetFocusOnError="True"
                  ValidationGroup="Pakke"
                 CssClass="errorOrdblindtest"></asp:RequiredFieldValidator>
           <asp:RegularExpressionValidator
              ID="RegularExpressionValidator3"
              runat="server"
              ErrorMessage=" - Byen som du kommer fra"
              ValidationExpression="^[a-zA-Z]{3, 70}$"
              ControlToValidate="TextBoxByen"
              Font-Bold="True"
              CssClass="errorOrdblindtest"
               ValidationGroup="Pakke"></asp:RegularExpressionValidator>
        </label>
        <asp:TextBox ID="TextBoxByen" runat="server" CssClass="form-control" ValidationGroup="Pakke"></asp:TextBox>
     </div>
     <div class="col-lg-3">
        <label for="exampleInputCompanyname-4">
           Post nr
              <asp:RequiredFieldValidator
                 ID="RequiredFieldValidator4"
                 runat="server"
                 ErrorMessage=" - Husk Post nr"
                 ControlToValidate="TextBoxPost"
                 Font-Bold="True"
                 SetFocusOnError="True"
                  ValidationGroup="Pakke"
                 CssClass="errorOrdblindtest" Enabled="True"></asp:RequiredFieldValidator>
           <asp:RegularExpressionValidator
              ID="RegularExpressionValidator4"
              runat="server"
              ErrorMessage=" - Din Postnr"
              ValidationExpression="^[0-9]{4}$"
              ControlToValidate="TextBoxPost"
              Font-Bold="True"
              CssClass="errorOrdblindtest"
               ValidationGroup="Pakke"></asp:RegularExpressionValidator>
        </label>
        <asp:TextBox ID="TextBoxPost" runat="server" CssClass="form-control" MaxLength="4" ValidationGroup="Pakke"></asp:TextBox>

因此,当我点击它时,它将被抛入数据库,而输入中没有任何内容。

<asp:Button ID="ButtonPay" OnClick="ButtonPay_Click" CssClass="btn btn-primary" runat="server" ValidationGroup="Pakke" />

0 个答案:

没有答案