limit how many dynamic form fields are shown and validate as image with javascript
===

I have the following jquery enabled javascript:

    jQuery(function($) {
      
      $('form').delegate('input[type=file]', 'change', function() {
        var form = $(this).closest('form');
        form.append('<input type="file">');
      });
      
    });

it will dynamically add a file upload field as the user add files they want to upload. how can I limit it to images only, and stop adding new fields after they've added 5 images?

thanks in advance