java java - 6 months ago 13
Javascript Question

Show hidden input javascript/jquery

Why is the hidden form not shown when the other input looses focus? The alert is coming up nicely when leaving the first input but the other hidden form is still not there.

html

<body>

<input type="text" id="myinput" value="">
<input type="hidden" id="validation_message_email" value="enter a valid email">

</body>


javascript

window.onload = function() {

$("#myinput").blur(myAlert);

};



function myAlert() {

alert("This input field has lost its focus.");
$("#validation_message_email").show();

}

Answer

You can't display a hidden input like that.A span will suit better for this purpose,

<input type="text" id="myinput" value="">
<span style="display:none"  id="validation_message_email">enter a valid email</span>