How to clear a file input?

I have a file input
<input type="file" id="files" name="files[]" multiple style="width:100%;" required/>
And when I the first time try to send without an image then it shows the alert “Select a file”, so the “required” is working as it should.

But when I have uploaded an image Im clearing the file input like this
$$(document).find('input[id=files]').val(null)

and I have tried with this as well

$$(document).find('input[id=files]').val('')

When I then try to upload without an image, the “required” is not working?

Thanks.