Limit the file inputs cloned in a form with Jquery
- by Philip
Hi, i use this Jquery function to clone the file input fields in my form,
$(function() {
var scntDiv = $('#clone');
var i = $('#clone p').size() + 1;
$('#addImg').live('click', function() {
$('<p><label for="attach"><input type="file" name="attachment_'+ i +'" /> <a href="#" id="remImg">Remove</a></label></p>').appendTo(scntDiv);
i++;
return false;
});
$('#remImg').live('click', function() {
if( i > 2 ) {
$(this).parents('p').remove();
i--;
}
return false;
});
});
is it possible to limit the fields that can be cloned? lets say a number of 4 fields?
thanks a lot,
Philip