Click here to Skip to main content
15,867,488 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have 4 textbox and its all loading when page get loaded. After that i want to hide the textbox 2 if no data is entered in to textbox 1.
Can any one help on this.!!!

I tried for radiobutton list which shown bellow .. but not idea on textbox how to do ...!!!

Thanks in advance..!!!

What I have tried:

function showHide(){
if(document.getElementById('rbtlstFees').value=='1')
{
document.getElementById('txtBxId').style.visibility='visible';
document.getElementById('txtBxId').style.display = 'block';
document.getElementById('lblId').style.visibility='visible';
document.getElementById('lblId').style.display = 'block';
}
else
{
document.getElementById('txtBxId').style.visibility='hidden';
document.getElementById('lblId').style.visibility='hidden';
}
}
Posted
Updated 21-May-18 19:42pm
v2
Comments
Sinisa Hajnal 4-Mar-16 3:32am    
You're looking for element.setAttribute("display", "none");
Or just add css class that hides the element (element,setAttribute("class", "hidden");
Mohibur Rashid 4-Mar-16 4:10am    
try
document.getElementById('lblId').style.display='none';

You can write code on change or on key press event of a particular textbox to show or hide control.

You can also use jquery to achieve this.

$(document).ready(
function() {
$('#test').keypress(

function() {
var value = document.getElementById('test').value;
alert(value);
});
})

<input id="test" type="text" />
 
Share this answer
 
Simple set Textbox's style.display property to 'none' for visible false, and set Textbox's style.display property to '' for visible true
JavaScript
//hide
document.getElementById("idOfTextField").style.display = 'none';

//visible
document.getElementById("idOfTextField").style.display = '';
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900