The code copy is as follows:
var xieYi=document.getElementById("xieYi");
if(!xieYi.checked){
alert("Please read first and check the registration agreement!");
return;
}
At the beginning, this is what I wrote, but not all cases require checking this agreement. The agreement sometimes does not appear on the front desk page, so the second one has been changed.
The code copy is as follows:
var xieYi=document.getElementById("xieYi");
if(!xieYi== null && !xieYi.checked){
alert("Please read first and check the registration agreement!");
return;
}
When xieYi does not exist, xieYi is null. When xieYi is judged not null and xieYi is not checked, alert.
Unfortunately, this code did not play the expected role.
Finally, I found out that the judgment was written incorrectly.
Final version:
The code copy is as follows:
var xieYi=document.getElementById("xieYi");
if(xieYi!= null && !xieYi.checked){
alert("Please read first and check the registration agreement!");
return;
}