Reputation: 712
i want to show button on the form after typing something inside input element in Jsp.
<input type="text" id="phoneNumber" name="Number" maxlength="10" size="15" onfocus="this.value=''" value="Enter your number" autocomplete="off">
<br/><br/>
<span style="color:red" class="title1" id="checkPhone"></span><br/>
<input type="submit" class="sendBtn" id="btSend" name="btSend" value="NextStep" style="display: none">
can you help me?
Upvotes: 2
Views: 3273
Reputation: 2144
Hope this works for you
$('#phoneNumber').focusout(function () {
if ($(this).val().length > 0) {
$('#btSend').show();
} else {
$('#btSend').hide();
}
});
Upvotes: 0
Reputation: 148180
You can use keyup
event of textbox to detect if something is typed in, also check if the textbox has some text to hide button if it is empty
$('input').keyup(function(){
if($.trim(this.value).length > 0)
$('#btSend').show()
else
$('#btSend').hide()
});
You might need to be specific about the inputs instead of doing it with all input elements e.g you can do it with inputs have some class
Upvotes: 4
Reputation: 193
Does this do what you need?
$('#phoneNumber').change(function() {
$('#btSend').show();
});
Upvotes: 1
Reputation: 370
var inp = $("#txt").val();
if(jQuery.trim(inp).length > 0)
{
$("#button").show();
}
Upvotes: 0