JavaScript没有使用CustomValidator

时间:2013-09-18 07:00:17

标签: javascript asp.net customvalidator

下面是我的JavaScript代码,但是当我尝试使用它时,它不起作用,我不知道为什么,有人可以帮助我。谢谢!

<script type="text/javascript" >
        function FatherClientValidate(oSrc, args) {
            var textBox = document.getElementById('<%=FatherName.ClientID%>');
            if (textBox.value != '') {

                var ctrlid = oSrc.id;
                var validatorid = document.getElementById(ctrlid);
                ctrlid = validatorid.controltovalidate;
                document.getElementById(ctrlid).style.backgroundColor = "#ff0000";
                args.IsValid = true;
            }
            else {
                var ctrlid = oSrc.id;
                var validatorid = document.getElementById(ctrlid);
                ctrlid = validatorid.controltovalidate;
                document.getElementById(ctrlid).style.backgroundColor = "White";
                args.IsValid = false;
            }
        }
    </script>

这是我的CustomValidator代码

<asp:requiredfieldvalidator Display="Dynamic" id="Requiredfieldvalidator25" runat="server" ForeColor="Red" errormessage="*Required" controltovalidate="FDateOfBirth" >
             <asp:CustomValidator  runat="server" ID="CustomValidator2"   ControlToValidate="FDateOfBirth" ClientValidationFunction="FatherClientValidate" ValidateEmptyText="true" EnableClientScript="true"></asp:CustomValidator>
            </asp:requiredfieldvalidator>

0 个答案:

没有答案