Javascript in form


What is the right/easiest way to add Javascript functions to a form?

I'm adding an upload button and want to set the TWebImageContainer image after the picture is chosen. I know there is no WebCore support for this , so I would like to do it directly in Javascript.


<label class="btn btn-xl btn-success">
    Dodaj priponko <input type="file" hidden name="imgFile" accept="image/gif, image/jpeg, image/png, image/bmp, image/tiff, image/tif, image/jfif, image/jpe">

Javascript code I would like to add:

$(":file").change(function () {
    if (this.files && this.files[0]) {
        var reader = new FileReader();
        reader.onload = imageIsLoaded;

function imageIsLoaded(e) {