locked
Not showing Erro RRS feed

  • Question

  • User-1499457942 posted

    Hi

      I have below code . When i click on Save there and there is nothing in txt_Target 

    <div id="div1" runat ="server">
            <div class="form-group row">
                <label for="Target" class="col-sm-2 col-form-label">Target</label>
                <div class="col-sm-2">
                    <asp:TextBox ID="txt_Target" CssClass="form-control" runat="server"></asp:TextBox>
                    <asp:RegularExpressionValidator ID="revtxt_Target" runat="server" ErrorMessage="Target Value can consist of Numeric Digits Only!" Display="Dynamic" ToolTip="Enter Numeric Digits Only
                     " ControlToValidate="txt_Target" ValidationExpression="^([1-9]\d*|0)(\.\d{1,2})?$"></asp:RegularExpressionValidator>
                    <asp:RangeValidator ID="rv1" CssClass="Validators" Display="Dynamic" MinimumValue="1" MaximumValue="100" Type="double" ControlToValidate="txt_Target"
                        runat="server" ErrorMessage="Target Range 0 to 100"></asp:RangeValidator>
                </div>
                
            </div>
        </div>

    Sunday, October 14, 2018 5:39 AM

Answers

  • User475983607 posted

    Add a required field validator.

    It helps if you take a few moments out of your day to read the validator documentation.  The Range and RegEx validators do not fire if the input is empty. This allows a design to  accept empty/null inputs. 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, October 14, 2018 11:55 AM
  • User61956409 posted

    Hi JagjitSingh,

    In documentation of RegularExpressionValidator control, we can find:

    Validation succeeds if the input control is empty. If a value is required for the associated input control, 
    use a RequiredFieldValidator control in addition to the RegularExpressionValidator control.

    With Regards,

    Fei Han

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, October 15, 2018 2:33 AM

All replies

  • User475983607 posted

    Add a required field validator.

    It helps if you take a few moments out of your day to read the validator documentation.  The Range and RegEx validators do not fire if the input is empty. This allows a design to  accept empty/null inputs. 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, October 14, 2018 11:55 AM
  • User61956409 posted

    Hi JagjitSingh,

    In documentation of RegularExpressionValidator control, we can find:

    Validation succeeds if the input control is empty. If a value is required for the associated input control, 
    use a RequiredFieldValidator control in addition to the RegularExpressionValidator control.

    With Regards,

    Fei Han

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, October 15, 2018 2:33 AM