dyarosh
asked on
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!
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
Also, how do I get the * to show next to the date field rather than below it?
Any help is greatly appreciated!
Well.. Try tabbing out of the textbox without entering any date.
ValidationSummary will be fired only on clicking of the submit button.
ValidationSummary will be fired only on clicking of the submit button.
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.
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.
ASKER
Is there a way to get the * to show up to the right of the textbox rather than below it?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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>
ASKER
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.
ASKER
Open in new window