2010-05-19 4 views

Répondre

3

Cela devrait le faire:

$(function(){ 
$('input[type="text"]').each(function(){ 
    if ($(this).val() === '') { 
    $(this).attr('disabled', 'disabled'); 
    } 
}); 
}); 

Si vous avez appliqué une classe à vos zones de texte, vous pouvez également faire:

$(function(){ 
$('.class_name').each(function(){ 
    if ($(this).val() === '') { 
    $(this).attr('disabled', 'disabled'); 
    } 
}); 
}); 
1
var empties = $('input:text').filter(function() { 
    return this.value == ''; // If the value of the input is empty, 
});       // add it to the collection 

empties.attr('disabled','disabled'); // Then disable the collection of empties 
Questions connexes