For a sample markup like this
<asp:Label ID="lblName" runat="server" Text="Enter Name:" ValidationGroup="test"></asp:Label>
<asp:TextBox ID="txtName" runat="server" ValidationGroup="test"></asp:TextBox>
<asp:Button ID="btnSubmit" runat="server" ValidationGroup="test" />
<asp:CustomValidator ControlToValidate="txtName" ID="cvName" ErrorMessage="error" Text="error"
runat="server" ClientValidationFunction="checkIfValExists" ValidateEmptyText="true" ValidationGroup="test"></asp:CustomValidator>
You can use a js function like this (jquery is used in here)
function checkIfValExists(source, args) {
var txt =$(source).prev().prev().prev().text();
if($(source).prev().prev().val().length == 0)
{
if (txt.length > 0 && txt.charAt(txt.length - 1) != '*') {
$(source).prev().prev().prev().text(txt + '*');
}
args.IsValid = false;
}
else
{
if(txt.length > 0 && txt.charAt(txt.length - 1) == '*' ){
$(source).prev().prev().prev().text(txt.substring(0, txt.length - 1));
}
}
}