forum

Home / DeveloperSection / Forums / Make text appear when submit button clicked and checkbox is unchecked

Make text appear when submit button clicked and checkbox is unchecked

Anonymous User 1830 31-Dec-2014
I am trying to create an agree to terms and agreements. However, when the button is unchecked and the user hits submit, I want it to present the user with an alert telling him to agree to the terms. At first, I made it to where the user couldn't even click on the submit button when the checkbox is unchecked, however, I want the user to be able to click it so he can be alerted with an error. I can't seem to get my code to work no matter what.

var checker = document.getElementById('checkme');
var sendbtn = document.getElementById('submit');
checker.onchange = function(){
if(this.checked){
    sendbtn.disabled = false;
} else {
    sendbtn.disabled = true;
}
if(document.getElementById('submit').click() & document.getElementById("myCheck").checked = false;){
            alert("Hello! I am an alert box!!");
}
}

<input type="checkbox" id="checkme"/>
I agree to the terms & service<br />
<input type="submit" name="sendNewSms" class="md-trigger blue-texture postbit-button-big md-pointer" data-modal="modal-five" id="submit" value=" Send "  onclick="$('.md-modal').removeClass('md-show');" disabled/>

Updated on 31-Dec-2014
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By