HIde button if all fields are blank
Hello. I have a form that runs a script when the button is clicked. I would like to add a feature that hides the button if the fields values are blank, and show it once all the fields contain a value.
I have this working script below, which fires an Alert on this condition, but don't know how to change it over to hide the button.
<script>
function formcheck() {
var fields = $(".myForm")
.find("select, textarea, input").serializeArray();
$.each(fields, function(i, field) {
if (!field.value)
alert(field.name + ' is required');
});
console.log(fields);
}
</script>
<form id="myForm" class="myForm">
<input name=f1 id="f1" placeholder="First Name" required="required">
<input name=f2 placeholder="MI" required="required">
<button class=copy name="copyBtn" id="copyBtn">Copy Info</button>
</form>