Monday, September 1, 2008

Hiding Custom-Validator, on entering data in form

While using Custom-Validator, you may have noticed that once you get the error-message of Custom-Validator, the message won't dissappear even if you enter data into the missing field. That means, Custom-Validator dont behave like other Validators.

However, you can overcome this scenario using the JavaScript class library provided by the Microsoft. Just include the code-segment before the closing tag. Thats all.

<script type="text/javascript">
// ValidatorHookupControlID function is contained within
// Microsoft's Validation Script

ValidatorHookupControlID("<%= TextBox1.ClientID %>", document.getElementById("<%= CustomValidator1.ClientID%><%= CustomValidator1.ClientID%>"));

ValidatorHookupControlID("<%= TextBox2.ClientID %>", document.getElementById("<%= CustomValidator1.ClientID%><%= CustomValidator1.ClientID%>"));
</script>


No comments:

 
Best viewed in Internet Explorer 8.