show only Error message of asp validators by javascript
<p>i trying to pop up only error message's for validation's control not text.
 The code which i tried is showing null for error message's. </p>

<pre><code>function fnOnUpdateValidators() {
            for (var i = 0; i &lt; Page_Validators.length; i++) {
                var val = Page_Validators[i];
                var ctrl = document.getElementById(val.controltovalidate);
                if (ctrl != null &amp;&amp; ctrl.style != null) {
                    if (!val.isvalid) {
                        ctrl.style.background = '#FFD6AD';
                        var errMsg = document.getElementById(val.id).getAttribute('ErrorMessage');
                        alert(errMsg);
                    }
                    else
                        ctrl.style.backgroundColor = '';
                }
            }
        }
</code></pre>
