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;
	}
}
</script>

In Page_Load
VB.NET


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

C#


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

Share with

Share on twitter
Share on facebook
Share on linkedin

Related FAQs

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

Please submit your question and answer.