---
title: "Make text appear when submit button clicked and checkbox is unchecked"  
description: "Make text appear when submit button clicked and checkbox is unchecked"  
author: "Anonymous User"  
published: 2014-12-31  
updated: 2014-12-31  
canonical: https://www.mindstick.com/forum/12834/make-text-appear-when-submit-button-clicked-and-checkbox-is-unchecked  
category: "jquery"  
tags: ["jquery", "javascript", "html"]  
reading_time: 2 minutes  

---

# Make text appear when submit button clicked and checkbox is unchecked

I [am trying](https://answers.mindstick.com/qa/36834/which-two-programming-languages-should-i-master-in-if-i-am-trying-to-get-into-google-or-facebook) to create an agree to [terms](https://answers.mindstick.com/qa/31698/what-is-the-real-value-of-us-dollars-in-terms-of-indian-rupee) and agreements. However, when the [button](https://www.mindstick.com/articles/63/how-to-add-button-in-datagridview-in-csharp-dot-net) is unchecked and the [user](https://www.mindstick.com/articles/13001/multi-statement-table-valued-user-defined-function-in-sql-server) hits submit, I want it to [present](https://answers.mindstick.com/qa/96635/explain-about-the-various-features-present-in-ms-access) the user with an [alert](https://answers.mindstick.com/qa/30927/what-is-an-alert) telling him to agree to the terms. At first, I made it to where the user couldn't even [click](https://www.mindstick.com/articles/12423/social-login-magento-2-one-click-to-register-social) on the submit button when the [checkbox](https://www.mindstick.com/articles/291/how-should-use-checkbox-control-in-vb-dot-net) 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](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii) 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/>
```

## Replies

### Reply by Elena Glibart

I want the user to be able to click it so he can be alerted with an error\
Remove the disabled from the submit button.Remove the checker.onchange = function(){Make sure to event.preventDefault(); browser triggering form submits or other default evett actionsAll you need:\
var checker = document.getElementById('checkme');var sendbtn = document.getElementById('submit');\
sendbtn.onclick = function( event ){ event.preventDefault(); if(!checker.checked){ alert("You must agree to our terms of service"); }};Note that you might want to do the above not on button Click but on formID.onsubmit (the form can always be submitted even without a Button click. Not seeing your form this is all I can suggest.)\
P.S:Developer Console (access by F12 and click Console) helps to debug such errors like &/&& =/=== missing ; etc...\
P.S2: when using only JS a handy function to fast-get an element by ID can be achieved with a nice little function i.e:\
function ID(id){return document.getElementById(id);} // ...and use like:var submitBtn = ID("submit");


---

Original Source: https://www.mindstick.com/forum/12834/make-text-appear-when-submit-button-clicked-and-checkbox-is-unchecked

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
