Live Chat Icon For mobile
Live Chat Icon

How to check/ uncheck a checkbox based on the text entered in textbox

Platform: ASP.NET| Category: Client Side Scripting

<asp:CheckBox id='CheckBox1' runat='server'></asp:CheckBox>
<asp:TextBox id='TextBox1' runat='server'></asp:TextBox>

<script type='text/javascript'>
function chkTextEntered()
	document.getElementById('CheckBox1').checked = true;
        	if(document.getElementById('TextBox1').value =='' )
		document.getElementById('CheckBox1').checked = false;

In Page_Load

TextBox1.Attributes.Add('onKeyDown', 'chkTextEntered();')


TextBox1.Attributes.Add('onKeyDown', 'chkTextEntered();');

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.