javascript - Check if text field is empty before executing jQuery -
this might easy question, find confusing.
how run myfunc() if textfield_1
not empty?
excicute .on('click', '#openbutton', myfunc)
if ($('#textfield_1').val()!="")
?
check inside handler:
.on('click', '#openbutton', function() { if( !$('#textfield_1').val().trim().length ) myfunc(); //thanks @mike suggestion on trim , length, see comments })
Comments
Post a Comment