How to make a Textbox required IF a Checkbox is checked

前端 未结 6 1116
忘掉有多难
忘掉有多难 2020-12-16 13:33

How can I make a textbox required if a checkbox is checked?

I figure I could write a custom validator, but I was hoping to avoid a full post back to check the valida

6条回答
  •  既然无缘
    2020-12-16 14:09

    You could make a custom validator, and then wrap those two controls in an UpdatePanel. That would turn it into an AJAX call for you. Kinda a waste, but it saves you having to write the JavaScript yourself.

    Also, if you hate writing JS as much as I do, you should try jQuery instead.

提交回复
热议问题