Simple JavaScript Checkbox Validation

前端 未结 11 2021
长情又很酷
长情又很酷 2020-12-10 03:56

I usually work with PHP so sadly don\'t have some basic JS principles down. This is all I want to accomplish--I\'ve seen many posts on this topic but they are usually beyon

11条回答
  •  孤街浪徒
    2020-12-10 04:27

    var testCheckbox = document.getElementById("checkbox");  
    if (!testCheckbox.checked) {
      alert("Error Message!!");
    }
    else {
      alert("Success Message!!");
    }
    

提交回复
热议问题