Reputation: 205
I wanna change customvalidator message dynamically in clientside by ClientValidationFunction. In java script I have :
function valnationalid(source, arguments) {
if (arguments.Value == ""){
source.errormessage = "custom message here";
arguments.IsValid = false;
} else if (arguments.Value == "Something else"){
source.errormessage = "another custom message here";
arguments.IsValid = false;
}
}
and in body:
<input runat="server" id="txtnationalid" maxLength="10" name="txtnationalid" class='person ltr glow-onfocus customerCode required number' dir="ltr" />
<asp:CustomValidator ID="valnationalid1" runat="server" EnableClientScript="true" ClientValidationFunction="valnationalid" ValidateEmptyText="True" Display="Dynamic" ControlToValidate="txtnationalid"> </asp:CustomValidator>
But no messages shows in my page.
Upvotes: 0
Views: 2563
Reputation: 2755
The following works for me:
Replace
source.errormessage = "custom message here";
With
source.innerHTML = "custom message here";
Upvotes: 1