Saturday, May 11, 2024
 Popular · Latest · Hot · Upcoming
10
rated 0 times [  14] [ 4]  / answers: 1 / hits: 17131  / 11 Years ago, tue, april 16, 2013, 12:00:00

How I can issue a pop up alert, such that when a user clicks a button, and a checkbox isn't checked, an alert will appear using jQuery?



The checkbox is:



<input type=checkbox id=confirm class=confirm>


The button is:



<form action=resetprocess.php method=POST>
<button type=submit id=reset class=btn btn-danger>Reset <i class=icon-repeat></i></button>
</form>

More From » jquery

 Answers
0

You need to capture the click event of your button and then check whether the checkbox is clicked or not. If not, you can send the alert and return false (be sure to do this otherwise the form will be submitted anyway).



$('#reset').click(function () {
if (!$('#confirm').is(':checked')) {
alert('not checked');
return false;
}
});


jsFiddle example


[#78860] Monday, April 15, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jaelynncherokeeg

Total Points: 697
Total Questions: 109
Total Answers: 104

Location: France
Member since Thu, Mar 18, 2021
3 Years ago
jaelynncherokeeg questions
Thu, May 27, 21, 00:00, 3 Years ago
Fri, Jan 24, 20, 00:00, 4 Years ago
Thu, Nov 14, 19, 00:00, 5 Years ago
Wed, Sep 18, 19, 00:00, 5 Years ago
;