I have the following html form which has a readonly "Base Price" field and I want to fill it with a value that will depend on the data that the other inputs have and then validate it with Javascript and Java (JSP, Servlets) to save them in a database.
<form class="col-lg-6 col-md-8 col-sm-12 mx-auto form-style">
<h1 class="text-center text-dark text-uppercase font-weight-bold">Registrar Nuevo Alquiler</h1>
<div class="form-group">
<label for="pisoOficina">Piso</label>
<input type="number" class="form-control" id="pisoOficina" placeholder="Piso" min="1" max="5">
</div>
<div class="form-group">
<label for="cantidadSillasOficina">Cantidad de Sillas</label>
<input type="number" class="form-control" id="cantidadSillasOficina" placeholder="Cantidad de Sillas" min="1">
</div>
<div class="form-group">
<label for="frenteVentanaOficina">¿Frente a Ventana?</label>
<select class="form-control" id="frenteVentanaOficina">
<option>Si</option>
<option>No</option>
</select>
</div>
<div class="form-group">
<label for="precioBaseOficina">Precio Base</label>
<input type="number" class="form-control" id="precioBaseOficina" placeholder="Precio Base" readonly>
</div>
<button type="submit" class="btn btn-dark w-100">AGREGAR ALQUILER</button>
</form>
For example, if the user enters the floor input value 1, then the base price will automatically be 2000, but if the user deletes the value 1 or changes the base price will change. I know ways to do it with a "Calculate Price" button but if there is any way that it would be automatic it would be more appropriate.