You can add a change event listener to the select
.
const input = document.querySelector('input');
const select = document.getElementById("shipping_option");
input.required = select.value === '1';
select.addEventListener('change', e=>{
input.required = select.value === '1';
});
<select required name="shipping_option" id="shipping_option">
<option selected value="1">1</option>
<option value="2">2</option>
</select>
I have this select and this input
<input type="text" name="input" placeholder="input">
How I can make this input required when the selected option is 1
?