In this post we will discuss how we can show or hide texbox based on checkbox using jQuery in asp.net. Here we have used a textbox, one checkbox. On checkbox checked or unchecked we are going to hide a textbox.
Also you can read:
- Date validation using JavaScript
- Split javascript string
- How to validate user input for mobile number using Regular Expression in Javascript?
Below is the full code:
On Check box checked or unchecked the textbox will be show or hidden.
Hope this will be helpful.
Also you can read:
- Date validation using JavaScript
- Split javascript string
- How to validate user input for mobile number using Regular Expression in Javascript?
Below is the full code:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#isCheckBox").on("click", function () {
if (document.getElementById('isCheckBox').checked) {
$("#txtMyTextBox").show();
} else {
$("#txtMyTextBox").hide();
}
});
});
</script>
<br />
<div class="row">
<div class="col-md-4">
<input type="checkbox" id="isCheckBox"/> I Agree<br />
<input type="text" id="txtMyTextBox"/><br />
</div>
</div>
On Check box checked or unchecked the textbox will be show or hidden.
Hope this will be helpful.