1

im working on an .aspx page in Visual Studio.

I want to have a text box that is followed by a drop down menu.

if the user enters any input in the text box id like for it and the drop down menu to both be required before the corresponding button can be clicked.

is the best way to do this to use a RequiredFieldValidator ?

4

5 に答える 5

1

あなたがやろうとしていることは条件付き検証だと思いますこの質問は、条件付き検証ASP.NETの質問に似ています

于 2012-06-07T18:01:21.467 に答える
0

両方のフィールドのバリデーターを作成し、テキストボックスのonblurでjavascriptを使用してバリデーターを有効/無効にすることができます。

HTML

<asp:TextBox runat="server" ID="txt" onblur="enableVaidators();" />

Javascript

function enableValidators()
{
   var val_Test = document.getElementById('<%=val_Test.ClientID%>');
   var enableValidators = true;

   // Perform check on whether to enable or disable based on your scenario

   ValidatorEnable(val_Test, enableValidators);
}
于 2012-06-07T17:56:02.583 に答える
0

はい、RequiredFieldValidatorあなたのシナリオではうまくいきます。「ユーザーがテキストボックスに入力した場合」に基づいて、必ず有効または無効にしてください

于 2012-06-07T17:52:35.563 に答える
0

jqueryを使ってみてはどうですか?

すべてがクライアント側で行われます:

http://docs.jquery.com/Plugins/Validation/

于 2012-06-07T17:56:28.433 に答える
0

TextBox の状態に基づいてロジックを実装する CustomValidator を使用します。

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.customvalidator.aspx

于 2012-06-07T17:59:20.297 に答える