Tech Rocks

Coldfusion
Java
JQuery

An online resource for latest web technologies like Coldfusion, JRun, Pro*C, JQuery, HTML5, PHP, W3C, Java, J2EE, C, C++, ORACLE, PL/SQL, MySql, Ajax, Coldbox, Fusebox, UNIX, JavaScript, NodeJS and much more...

Sunday, April 10, 2011

Checkbox validation using jquery

Example:

function validate_1(val){
    var msg = "";
    var chk  = false;
    if(val == 6) {
        $("[name='zzz']").each(function() { 
            //alert($(this).is(':checked'));
            if($(this).is(':checked')) chk = true;   
        });
        if(!chk) msg = msg + "zzz is required\n";
    }
    if(val == 7) {
        $("[name='zzz']").each(function() { 
            //alert($(this).is(':checked'));
            if($(this).is(':checked')) chk = true;   
        });
        if(!chk) msg = msg + "zzz is required\n";
    }
    if(msg != ""){
        alert(msg);
        return false;
    } else {
        return true;
    }
}

0 comments :

Post a Comment