I searched for tutorials and I didn't find anything, someone went through this?
<div class="row">
<div class="col-md-2">
Valor:<br />
<input type="number" class="form-control" id="txtvalor" value="0" Placeholder="Valor" />
</div>
<div class="col-md-2">
Porcentaje:<br />
<input type="number" class="form-control" id="txtporcentaje" value="0" placeholder="Porcentaje" />
</div>
<div class="col-md-2" style="vertical-align:bottom">
<button type="submit" class="btn btn-primary" id="btngravadescuentos"> Cargar </button>
</div>
</div>
When pressing load it has to validate if only one is filled, if neither is filled it makes a required and if I want to fill in both it does not have to let me fill
I accept any suggestion
THIS ARRIVED
1.- Select Discount is by default and is an empty value - a required if I press the "Select a discount" button
2.- a required if you press the button and the percentage or value fields are not filled
3.- a message (no alert) that says just fill in a field "value or percentage"
The script would be something like this:
how about you try using jquery and change the logic so that if the user wants to enter more than one textbox the other one will be cleared? and regarding that it is required you can also use jquery and its plugin validate plugin
You can disable the other input when one of them is filled.
In the button you simply have to check that they are not both empty: