var xieYi=document.getElementById("xieYi");
if(!xieYi.checked){
alert("Please read and check the registration agreement first!");
return;
}
It was originally written like this, but not all situations require checking this agreement. Sometimes the agreement will not be displayed on the front page, so I changed it to the second one
var xieYi=document.getElementById("xieYi");
if(!xieYi== null && !xieYi.checked){
alert("Please read and check the registration agreement first!");
return;
}
When xieYi does not exist, xieYi is null. When it is judged that xieYi is not null and xieYi is not checked, it will alert.
Unfortunately, this code did not work as expected.
Finally, I found out that I had written xieYi wrong.
Final version:
var xieYi=document.getElementById("xieYi");
if(xieYi!= null && !xieYi.checked){
alert("Please read and check the registration agreement first!");
return;
}