<html>
<form class="form-disable">
<br>
<input type="text" id="message2">
<br>
<button id="myButton" type="submit" onclick="text()"disabled>Generate Text</button>
</form>
</html>
<script>
// $("html").click(function(event){
// $("#myButton").attr("disabled", "disabled");
// event.preventDefault();
// })
function text(){
let $box = $('#message2').val();
alert($box);
}
$("#message2").click(function(){
$("#myButton").removeAttr("disabled");
// event.preventDefault();
})
</script>
I've tried using the commented out function with an alert and it seems to make an alert appear anytime I click anywhere on the screen. So, I'm afraid that my problem is that the commented out function is also adding the disabled attribute when I click on the text input field. When the function is commented out the submit button is disabled until I click on the input field, but I can't figure out how to make the button disabled once the user clicks out of the input box/field.