Reputation: 1673
I'm using ASP.NET Pages and CustomValidator control to validate set of controls. Also I'm using ClientValidation property and my custom javascript function. My main issue is : when I setting 'ControlToValidate' property - validation function stop calling. I've check everything twice, set ID's for validator and control to validate, but still no result.
Does anybody know how to fix my situation?
P.S. Main reason why I need to set ControlToValidate property is that I want to fire validation stright after lost control focus
UPDATE : here is validator :
<asp:CustomValidator ID="cvEmail1" runat="server" ClientValidationFunction="ValidateEmail"
Display="Dynamic" EnableClientScript="True" ForeColor="Red" ErrorMessage="This field is required"/>
and thi is validation function :
<script type="text/javascript">
function ValidateEmail(sender, args) {
var isValid = myCheck();
args.IsValid = isValid;
}
</script>
Upvotes: 1
Views: 2048
Reputation: 50728
A CustomValidator with no ControlToValidate property set validates on every postback. When you establish the ID of another control, it will only validate when that control has a value to validate; it will not validate empty text. Set ValidateEmptyText to true to enable that.
Also, you may want to post your setup, so we can assist further.
Upvotes: 2