Change upload button to not mandatory

Hi! I want to change an upload button to not mandatory if an option on a dropdown is selected, I don’t know if that is possible.
I need the button to be mandatory by default, but if an option on the dropdown is selected I don’t need the file to be submitted.

$w.onReady(() =>
    $w("#dropdown1").onChange(event =>{
        if($w("#dropdown1").value === "someValue"){
            $w("#uploadButton").required = false;
        } else {
            $w("#uploadButton").required = true;
        }
    })
})

Thanks!