var status; var nm = ["name"]; function simpleCheck(nam) { $(nam).each( function() { var wh = $(this)[0]; var vals = $("input[@id='"+wh+"']").val(); if ( vals == '' || vals == null ){ if ($("#er_"+wh).css("display") == 'none' ) { $("#er_"+wh).css("display","inline"); if (!status) $("input[@id='"+wh+"']").focus(); } status = 1; } else { $("#er_"+wh).css("display","none"); status = (status) ? 1:0; } }); } function checkForm() { status = 0; simpleCheck(nm); var vals = $("textarea[@id='text']").val(); if ( vals == '' || vals == null ){ if ($("#er_text").css("display") == 'none' ) { $("#er_text").css("display","inline"); if (!status) $("textarea[@id='text']").focus(); } status = 1; } else { $("#er_text").css("display","none"); status = (status) ? 1:0; } var val_code = $("input[@id='yourcode']").val(); if ( val_code == '' || val_code == null || val_code.length != 3 || !parseInt(val_code)){ if ($("#er_yourcode").css("display") == 'none' ) { $("#er_yourcode").css("display","inline"); if (!status) $("input[@id='yourcode']").focus(); } status = 1; } else { $("#er_yourcode").css("display","none"); status = (status) ? 1:0; } if (!status) return true; return false; }