Questions about idiots-check for js verification

Source: Internet
Author: User
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?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.