Idiot problem --- check for js verification. dear friends, my code is like this: & lt; form & nbsp; action & nbsp ;=& nbsp; "reponse. php "& nbsp; name =" form1 "& nbsp; method & nbsp; = & nbsp;" post "& gt; & nbsp; & nbsp; idiot question --- check for js verification.
Dear friends, my code is as follows:
I want to add a js check for this check. if one is not selected, it will stay on the original page and issue a warning. If yes, it will jump to reponse. php. I tried a lot of js codes on the Internet, but none of them were successful. how do you write this js code? Share :????
9 .? A? Qu... 'data-pics = ''>
------ Solution --------------------
I wrote it casually, but I haven't verified it. the general idea is this.
$ ("Input [name = 'submit ']"). click (function (){
If ($ ("input [name = 'activite [] ']"). attr ("checked") = false ){
Alert ('select at least one ');
}
Else {
Location. herf = "reponse. php ";
}
});
------ Solution --------------------
When the check fails, you need to return false to prevent the page from redirecting. Otherwise, the page will jump even though the check is out. So after the code that prompts the warning, follow a return false;
The code will not be written. I haven't written PHP for a long time. forget it, huh, huh.
------ Solution --------------------
Script
Function func (obj ){
Var boxs = obj. elements ['activite [] '];
Var counter = 0;
For (var I = 0; I
If (boxs [I]. checked) counter ++
}
If (counter = 0 ){
Alert ('must be selected ');
Return false;
}
Return true;
}
Script
------ Solution --------------------
JQUERY verification:
Script
Function formValidate (){
If ($ (": checked"). length = 0 ){
Alert ('Brother, choose either? ');
Return false;
} Else {
Return true;
}
}
Script
9. A quelle (s) famille (s) Activ 'age vos activit é s appartiennent-elles?