locked
ajaxToolkit:MaskedEditValidator - One label place for multiple validation errors RRS feed

  • Question

  • User-1849627223 posted

    Hello!

    How can I set one place for all validation errors?
    I have several MaskedEditValidators in one form and I would like the errors not to be displayed next to the textbox, just like in the picture.

    Best regards,

    B.

    Wednesday, December 9, 2020 10:13 PM

All replies

  • User-939850651 posted

    Hi BSiedlecki,

    I'm not sure what you want to achieve, if you just want to change the location of the error message.

    Just do something like this:

        <form id="form1" runat="server">
            <asp:ScriptManager ID="ScriptManager1" runat="server" />
            <div>
                <br />
                <br />
                User Name: 
                <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    
                <ajaxToolkit:MaskedEditExtender ID="MaskedEditExtender1"
                    runat="server"
                    TargetControlID="TextBox1"
                    Mask="99/99/9999"
                    MaskType="Date"
                    MessageValidatorTip="true"
                    OnFocusCssClass="MaskedEditFocus"
                    OnInvalidCssClass="MaskedEditError" />
    
                <br />
                <br />
                Email Address:  
                <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
                <ajaxToolkit:MaskedEditExtender ID="MaskedEditExtender2"
                    runat="server"
                    TargetControlID="TextBox2"
                    Mask="99,999.99"
                    MaskType="Number"
                    MessageValidatorTip="true"
                    OnFocusCssClass="MaskedEditFocus"
                    OnInvalidCssClass="MaskedEditError"
                    InputDirection="RightToLeft"
                    DisplayMoney="Left"
                    AcceptNegative="Left" />
    
                <br />
                <br />
                Password: 
                <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
                <ajaxToolkit:MaskedEditExtender ID="MaskedEditExtender3"
                    runat="server"
                    TargetControlID="TextBox3"
                    Mask="99:99:99"
                    MaskType="Time"
                    MessageValidatorTip="true"
                    OnFocusCssClass="MaskedEditFocus"
                    OnInvalidCssClass="MaskedEditError"
                    AcceptAMPM="true" />
    
                <br />
                <br />
                <div style="width: 300px; height: 150px; border: 1px solid black">
                    <h4>Please fix the following errors:</h4>
                    <ul>
                        <li>
                            <ajaxToolkit:MaskedEditValidator ID="MaskedEditValidator1"
                                runat="server"
                                ControlToValidate="TextBox1"
                                ControlExtender="MaskedEditExtender1"
                                Display="Dynamic"
                                TooltipMessage="PLease enter a date"
                                IsValidEmpty="false"
                                EmptyValueMessage="A Date is Required"
                                InvalidValueMessage="Ths date is invalid" />
                        </li>
                        <li>
                            <ajaxToolkit:MaskedEditValidator ID="MaskedEditValidator2"
                                runat="server"
                                ControlToValidate="TextBox2"
                                ControlExtender="MaskedEditExtender2"
                                Display="Dynamic"
                                TooltipMessage="Please enter a value between -100 and 12000"
                                IsValidEmpty="false"
                                EmptyValueMessage="A Number is Required"
                                InvalidValueMessage="This Number is invalid"
                                MinimumValue="-100"
                                MinimumValueMessage="The value is too small." MaximumValue="12000"
                                MaximumValueMessage="The number is too large" />
                        </li>
                        <li>
                            <ajaxToolkit:MaskedEditValidator ID="MaskedEditValidator3"
                                runat="server"
                                ControlToValidate="TextBox3"
                                ControlExtender="MaskedEditExtender3"
                                Display="Dynamic"
                                TooltipMessage="Please Enter a Time"
                                IsValidEmpty="false"
                                EmptyValueMessage="A Time is Required"
                                InvalidValueMessage="This Time is invalid" /></li>
                    </ul>
                </div>
                <asp:Button Text="text" runat="server" ID="sumbitBtn" />
            </div>
        </form>

    Result:

    And this validator is usually used to verify the date or amount. I think it is not suitable for your requirements.  RequiredFieldValidator may be more suitable.

    Best regards,

    Xudong Peng

    Thursday, December 10, 2020 7:10 AM