function attachValidator(a){$(a).submit(function(){if($("input.error").length>0){var b=$("input.error").length>1?$("input.error").length+" errori":"un errore";alert("La form contiene "+b);return false}return true});$(":input.jval").each(function(){$(this).blur(function(){$("#invio").attr("disabled","disabled");fld_name=$(this).attr("name");fld_id=$(this).attr("id");$("#"+fld_id).after("<span id='loader-"+fld_id+"'><img src='images/loader.gif' width=16 height=11 /></span>");$(this).attr("disabled","disabled");$.post("validator.php",{field:fld_name,value:$(this).val()},function(b){if(b.validated){$("#"+fld_id).removeClass("error");$("label.error[for='"+fld_id+"']").remove()}else{$("#"+fld_id).addClass("error")}$("#"+fld_id).after("<label for='"+fld_id+"' class='error'>"+b.message+"</label>")},"json").error(function(){alert("Errore server")}).complete(function(){$("#loader-"+fld_id).remove();$("#"+fld_id).removeAttr("disabled");$("#invio").removeAttr("disabled")})}).focus(function(){var b=$(this).attr("id");$("label.error[for='"+b+"']").remove();$("#"+b).removeClass("error")})})};
