The ValidationSummary panel shows up, even if the validator does not have an 'ErrorMessage'. When I click on Submit with invalid login, the error shows up in summary. That part's fine. When I submit with empty textboxes, it should show only the '*', but it also shows an empty summary panel. How can I prevent this. [Have a css class for .summary,header, summary ul, .summary ul li].
JS:
function validateTextBox(sender, args) {
var target = document.getElementById(sender.controltovalidate);
var is_valid = target.value != "";
if (is_valid) {
target.className = "";
}
else {
target.className = "validate";
}
args.IsValid = is_valid;
}
ASPX:
<asp:ValidationSummary ID="vs" runat="server" CssClass="summary"
ValidationGroup="vsGroup" DisplayMode="BulletList" EnableClientScript="true"
HeaderText="<div class='header'> Please Correct The
Following</div>" />
<asp:TextBox ID="txtSurname" runat="server" class=""></asp:TextBox>
<asp:CustomValidator ID="CustomValidator1" runat="server"
ValidationGroup="vsGroup" ControlToValidate="txtSurname"
ClientValidationFunction="validateTextBox" Text="*"
ForeColor="Red" ValidateEmptyText="true" ></asp:CustomValidator>
<asp:TextBox ID="txtLogin" runat="server" class=""></asp:TextBox>
//....CustomValidator2 just as above..
<asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server"
ControlToValidate="txtLogin" Text="*" ForeColor="Red"
ValidationExpression="^[a-z]{8,10}$" Display="Dynamic"
ErrorMessage="Login Does Not Match The Requirements" ValidationGroup="vsGroup"
EnableClientScript="true"></asp:RegularExpressionValidator>
<asp:Button ID="btnSubmit" runat="server" Text="Submit" ValidationGroup="vsGroup" />