jQuery : check if the textbox has text or empty Hi guys, what I'm trying to accomplish is. when the textarea is empty it will show a specific button. but when the textarea has value it will show another button. but if they remove the value it will show the other button again.
here is my code
$('#leadnote').on('keyup keypress', function(e) {
if($(this).val().length >0) {
alert('not null');
}
});
$('#leadnote').on('change', function() {
if($(this).val().length = 0) {
alert('null');
}
})
so far when i try to put text on the textarea it will allert not null, but when i remove the text it won't alert null.
Try this.
$('#emailsignin').on('keyup keypress', function(e) {
if($(this).val().length =>0) {
alert('not null');
}
});
$('#emailsignin').on('keyup', function() {
if($(this).val().length == 0) {
alert('null');
}
})
It looks your onChange function is not working
@zainudinnoori it worked!. thank you!.
i have to change this
if($(this).val().length =>0) {
to this to work
if($(this).val().length >= 1) {
Please sign in or create an account to participate in this conversation.