RegularExpressionValidator Error Message doesn't show up in the ValidationSummary in ASP.NET

I have an ASP.Net page that has a date field on it.  I have 2 validation controls on the date field: RequiredFieldValidator and RegularExpressionValidator.  If I click on my Retrieve button without entering a date I get the Hire Date Required message from the RequiredFieldValidator in the ValidationSummary.

If I enter an invalid date in the date field and tab away, I only get the * and don't get the message in the ValidationSummary.  I've verified that I've used the same name for the ValidationGroup.  If I hit my Retrieve button I then get the Invalid Date Entered message.

How do I get the RegularExpressionValidator to display the message in the ValidationSummary like the RequiredFieldValidator?

Also, how do I get the * to show next to the date field rather than below it?

Any help is greatly appreciated!
dyaroshAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

dyaroshAuthor Commented:
I forgot to post my markup.  Here it is:

    <asp:ValidationSummary ID="ValidationSummary1" ValidationGroup="NewHireEmails" runat="server" BackColor="Red" BorderStyle="solid" Font-Bold="True" ForeColor="White" />
    <table>
        <tr>
            <td>Enter the Hire Date to Report:</td>
            <td>
                <asp:TextBox ID="txtHireDate" runat="server" MaxLength="10" Text="" ClientIDMode="Static"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                    ErrorMessage="Hire Date Required"  ValidationGroup="NewHireEmails"
                    ControlToValidate="txtHireDate" Display="Dynamic" 
                    ToolTip="Enter Hire Date" BackColor="Red" Font-Bold="True" ForeColor="White" SetFocusOnError="True" Text="*"></asp:RequiredFieldValidator>
                <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" 
                    ErrorMessage="Invalid Date entered" ControlToValidate="txtHireDate" Display="Dynamic"  
                    ToolTip="Enter a date in the format MM/DD/YYYY or MM/DD/YY" Text="Invalid Date entered"
                    ValidationGroup="NewHireEmails"  BackColor="Red" Font-Bold="True" ForeColor="White"
                    ValidationExpression="^(((((((0?[13578])|(1[02]))[\.\-/]((0?[1-9])|([12]\d)|(3[01])))|(((0?[469])|(11))[\.\-/]((0?[1-9])|([12]\d)|(30)))|((0?2)[\.\-/]((0?[1-9])|(1\d)|(2[0-8]))))[\.\-/](((19)|(20))?([\d][\d]))))|((0?2)[\.\-/](29)[\.\-/](((19)|(20))?(([02468][048])|([13579][26])))))$"></asp:RegularExpressionValidator>
            </td>
        </tr>
        <tr>
            <td><asp:Button ID="btnRetrieveNewHires" runat="server" Text="Retrieve New Hires" validationgroup="NewHireEmails"
                    onclick="btnRetrieveNewHires_Click" /></td>
            <td><asp:Button ID="btnSendEmail" runat="server" Text="Send Emails" OnClick="btnSendEmail_Click" Enabled="false" /></td>
            <td><asp:Button ID="btnSaveFile" runat="server" Text="Export To Excel" OnClick="btnSaveFile_Click" Enabled="false" /></td>
            <td><asp:Button ID="btnReturn" runat="server" ClientIDMode="Static"
                    Text="Return to Employee Profile Menu" onclick="btnReturn_Click" /></td>
        </tr>
    </table>

Open in new window

0
Obadiah ChristopherCommented:
Well.. Try tabbing out of the textbox without entering any date.

ValidationSummary will be fired only on clicking of the submit button.
0
Jitendra PatilSr.Software EngineerCommented:
The Validation Summary is displayed when you try to submit the form (click the submit button), and not exactly after you fill in the form fields.

If you have Display="Dynamic" on your validator, like you have, the only thing you'll instantly get is the message in your validator's Text property. So, if you want to instantly get the error message,
you'll have to set Text="Invalid date Entered".

hope this helps.
0
Build an E-Commerce Site with Angular 5

Learn how to build an E-Commerce site with Angular 5, a JavaScript framework used by developers to build web, desktop, and mobile applications.

dyaroshAuthor Commented:
Is there a way to get the * to show up to the right of the textbox rather than below it?
0
Jitendra PatilSr.Software EngineerCommented:
it may be your designing issue.

when you keep a regular expression validator besided textbox it will show it on the right side only (if kept on rhs).

if you have kept <br> tag between textbox and validator then just remove it.

as your markup code displays * on the right side only when i tried your code on my machine.

hope this helps.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dyaroshAuthor Commented:
What browser and version are you using?  Here is my markup and the error message still appears below the textbox.

                <asp:TextBox ID="txtHireDate" runat="server" MaxLength="10" Text="" ClientIDMode="Static"></asp:TextBox><asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" 
                    ErrorMessage="Invalid Date entered" ControlToValidate="txtHireDate" Display="Dynamic"  
                    ToolTip="Enter a date in the format MM/DD/YYYY or MM/DD/YY" Text="Invalid Date entered"
                    BackColor="Red" Font-Bold="True" ForeColor="White"
                    ValidationExpression="^(((((((0?[13578])|(1[02]))[\.\-/]((0?[1-9])|([12]\d)|(3[01])))|(((0?[469])|(11))[\.\-/]((0?[1-9])|([12]\d)|(30)))|((0?2)[\.\-/]((0?[1-9])|(1\d)|(2[0-8]))))[\.\-/](((19)|(20))?([\d][\d]))))|((0?2)[\.\-/](29)[\.\-/](((19)|(20))?(([02468][048])|([13579][26])))))$"></asp:RegularExpressionValidator>

Open in new window

0
dyaroshAuthor Commented:
I ended up having to put a width on my textbox in order to get the error message to display to the right of the textbox.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.