Checkbox to judge code analysis
- 2020-03-30 03:18:49
- OfStack
var xieYi=document.getElementById("xieYi");
if(!xieYi.checked){
alert(" Please read and check the registration agreement first! ");
return;
}
It was written like this at the beginning, but not all cases need to check the protocol, sometimes the protocol will not be displayed in the front page, so the second change
var xieYi=document.getElementById("xieYi");
if(!xieYi== null && !xieYi.checked){
alert(" Please read and check the registration agreement first! ");
return;
}
XieYi is null when xieYi does not exist, alert when xieYi is not null and xieYi is not checked.
Unfortunately, this code didn't work as intended.
It turned out that xieYi had written it wrong.
The final version:
var xieYi=document.getElementById("xieYi");
if(xieYi!= null && !xieYi.checked){
alert(" Please read and check the registration agreement first! ");
return;
}