Anyname Donotcare Anyname Donotcare -3 years ago 93
ASP.NET (C#) Question

Change from text box appearance to label appeareance according to the focus

I have a template field in my

,this template field is a (text box).What i wanna to do is :After the user finished the writing and move to the next textbox , the one which lose the focus turned to be a label or like a label , and if it gets the focus again turn to be a text box.and ...etc

How to do some thing like this?

Answer Source

Like so :

<script type="text/javascript">
function show(){
document.getElementById("input1-label").style.display = "none";
document.getElementById("input1").style.display = "block";

function hide(){
if(document.getElementById("input1").value != "") document.getElementById("input1-label").innerHTML = document.getElementById("input1").value;
document.getElementById("input1-label").style.display = "block";
document.getElementById("input1").style.display = "none";

<label id="input1-label" onclick="show()" style="display:none">Label</label>
<input type="text" id="input1" onblur="hide()" />

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download