2

最初に、私はこのトピックに関する他のスレッドを見てきました、そして私は私が立ち往生している何かを片付けたいだけです。

このテキストボックスコントロールと必須フィールドバリデーターがあります。

<td class="style1">
    <asp:TextBox runat="server" ID="txtFirstname"></asp:TextBox>
</td>
<td>
    <asp:RequiredFieldValidator ID="rfvFirstname" runat="server"   ControlToValidate="txtFirstname" >*</asp:RequiredFieldValidator>
</td>

そしてこのjavascriptコード

<script type="text/javascript">
    function chkValidators() {
        alert("enter function chkValidators");
        validatorEnable(document.getElementById('<%rfvFirstname%>'), false);
    }

これにより、コンパイルエラーが発生します。

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. 

Compiler Error Message: CS1002: ; expected

Source Error:

Line 158:            #line default
Line 159:            #line hidden
Line 160:            @__w.Write("\'), false);\r\n         }\r\n   </script>\r\n");
Line 161:        }
Line 162:        

誰もがこれを修正する方法を知っていますか?

ニック

4

4 に答える 4

4

使ってみましたか..

    ValidatorEnable(document.getElementById('<%= rfvFirstname.ClientID %>'), false);
于 2012-09-19T11:19:18.757 に答える
0

ValidatorEnable() が機能しなかった場合、これは機能します。

  document.getElementById("<%=rfvFirstname.ClientID %>").enabled = false;
于 2015-09-22T23:31:25.230 に答える
0

バリデーターを無効にし、Checkbox onclick イベントでエラー テキストをクリアするスクリプトを次に示します。

<script language="javascript" type="text/javascript">

       function chktextmiddlenameEnableDisable(obj) {

             document.getElementById('<%=txtMiddleName.ClientID %>').disabled = obj;
             if (obj == true) {
                     document.getElementById('<%=RequiredFieldValidator2.ClientID %>').innerHTML = '';
                     } else {
                              document.getElementById('<%=RequiredFieldValidator2.ClientID %>').innerHTML = 'Please Enter Middle Name';
                     }
              } 


 </script>

チェックボックスのonclickイベントで私が呼んだonclick="chktextmiddlenameEnableDisable(this.checked);"

于 2015-09-18T02:52:05.520 に答える