Javascript Can';t重写有效的asp.net

Javascript Can';t重写有效的asp.net,javascript,jquery,asp.net,Javascript,Jquery,Asp.net,我正在尝试使用此方法验证我的表单 我的网站是asp.NET4.6WebForm 我使用的母版页中有所有的脚本参考。 在我的页面中,我插入了 <div class="form-group"> <asp:TextBox runat="server" ID="txtNomeOperatore" CssClass="form-control"></asp:

我正在尝试使用此方法验证我的表单

我的网站是asp.NET4.6WebForm

我使用的母版页中有所有的脚本参考。 在我的页面中,我插入了

<div class="form-group">                                                        
   <asp:TextBox runat="server" ID="txtNomeOperatore" CssClass="form-control"></asp:TextBox>                            
   <span class="help-block">Operatore</span>
   <asp:RequiredFieldValidator runat="server" ID="NomeOperatoreValidator" Text="Errore richiamato" ControlToValidate="txtNomeOperatore" Display="Dynamic" EnableClientScript="true" ></asp:RequiredFieldValidator>
</div>

操作员
在页面末尾,我插入了Javascript代码:

<script>
        ValidatorUpdateIsValid = function () {
            Page_IsValid = AllValidatorsValid(Page_Validators);
            SetValidatorStyles();
        }

        SetValidatorStyles = function () {
            var i;
            // clear all
            for (i = 0; i < Page_Validators.length; i++) {
                var inputControl = document.getElementById(Page_Validators[i].controltovalidate);
                if (null != inputControl) {
                    WebForm_RemoveClassName(inputControl, 'validate-error');
                }
            }
            // set invalid
            for (i = 0; i < Page_Validators.length; i++) {
                inputControl = document.getElementById(Page_Validators[i].controltovalidate);
                if (null != inputControl && !Page_Validators[i].isvalid) {
                    WebForm_AppendToClassName(inputControl, 'validate-error');
                }
            }

        }
</script>

ValidatorUpdatesValid=函数(){
Page_IsValid=AllValidatorsValid(Page_Validators);
SetValidatorStyles();
}
SetValidatorStyles=函数(){
var i;
//清除所有
对于(i=0;i
但当我尝试验证样式时,它并没有应用于我的控件
我哪里错了?

我已经测试了这个片段。它可以工作,并且类被添加/删除。一定是别的什么原因导致了这个问题。当然……但是什么呢?