0

ClientValidationFunction によってクライアント側で customvalidator メッセージを動的に変更したい。私が持っているJavaスクリプトでは:

function valnationalid(source, arguments) {     
    if (arguments.Value == ""){         
        source.errormessage = "custom message here";
        arguments.IsValid = false;
    } else if (arguments.Value == "Something else"){
        source.errormessage = "another custom message here";
        arguments.IsValid = false;
    }
}

そして体内:

<input runat="server" id="txtnationalid" maxLength="10" name="txtnationalid" class='person ltr glow-onfocus customerCode required number' dir="ltr" />
<asp:CustomValidator ID="valnationalid1" runat="server" EnableClientScript="true" ClientValidationFunction="valnationalid"  ValidateEmptyText="True" Display="Dynamic" ControlToValidate="txtnationalid"> </asp:CustomValidator>                            

しかし、私のページにはメッセージが表示されません。

4

1 に答える 1

1

以下は私にとってはうまくいきます:

交換

source.errormessage = "custom message here";

source.innerHTML = "custom message here";
于 2013-03-05T10:47:11.347 に答える