jQuery(document).ready(function($){
console.log("pret");
$('.frm_button_submit').css('visibility','hidden');
$(document).bind('keyup change','.frm_opt_container input', function() {
console.log("Key detected");
var ok = true;
//check si cahque container est filled
$('.frm_required_field .frm_opt_container:visible').each(function(index) {
console.log($(this)); //check si il y au moins un field coche
var fields_empty = true;
$(this).find("input[type=checkbox], input[type=radio]").each(function(index) {
if ( $(this).is(':checked') ) {
fields_empty = false;
return false;
}
});
if(fields_empty){
console.log("Ce container est vide : " + index);
ok = false;
return false;
} });
//check si les input text sont vides
var input_not_text = '.frm_required_field:visible input:not(:checkbox):not(:radio)';
$(input_not_text).each(function(index) {
if ( $(this).val().length == 0 ) {
console.log("Ce input texte est vide : " + index);
ok = false;
return false;
}
});
console.log("affiahge du bouton ?" + ok);
if (!ok) {
jQuery('.frm_button_submit').css('visibility','hidden');
} else {
jQuery('.frm_button_submit').css('visibility','visible');
}
});
});
Please login or Register to submit your answer