Im trying to disable my Graph Button when values are empty in ALL the textfield that i have.. and if all the textfields has values it will be enabled. It worked fine for me but whenever i click the Add Entry button to append a new Textfields Graph button will still be enabled even though Textfields are empty, it happens everytime i fill up all textfields and it will enable and when i click Graph button it will show another empty textfields but Graph button is still enabled. here is my code
In HTML
<body>
<button id="myBtn" class="btn">Add Entry</button>
<div id="myForm"></div>
<br/>
<button id="btnGraph" class="btn">Graph</button>
</body>
In Jquery
$(document).ready(function()
{
$("#myBtn").click(function()
{
addCountry();
$("input[class^='text']").keyup(function(e)
{
var alltxt = $("input[class^='text']").length;
var empty = true;
$("input[class^='text']").each(function(i)
{
if($(this).val()=='')
{
empty=true;
$('#btnGraph').prop('disabled', true);
return false;
}
else
{
empty=false;
}
});
if(!empty)
$('#btnGraph').prop('disabled', false);
});
});
});