Not sure I even know how to ask this, so please bear with me. There is a group of radio buttons on the form to check for specific dollar amounts. The group also includes a button for “Other Amount.” Then there is a field for the Other Amount to be entered. The problem is how to make the Other Amount Field mandatory if Other Amount radio button is checked.
Here is the html
<div class="">
<h4><strong>Donation Amount</strong></h4>
<label class="radio-inline">
<input class="radio" type="radio" name="amount" value="$20"> <span>$20</span>
</label>
<label class="radio-inline">
<input class="radio" type="radio" name="amount" value="$25"> <span>$25</span>
</label>
<label class="radio-inline">
<input class="radio" type="radio" name="amount" value="$50"> <span>$50</span>
</label>
<label class="radio-inline">
<input class="radio" type="radio" name="amount" value="$75"> <span>$75</span>
</label>
<label class="radio-inline">
<input class="radio" type="radio" name="amount" value="$100"> <span>$100</span>
</label>
<label class="radio-inline">
<input class="radio" type="radio" name="amount" value="other"> <span>Other</span>
</label>
</div>
<div class="form-inline mt-2">
<label>
<h4><strong>$ </strong></h4>
<input type="text" class="form-control" id="inputNumber" name="number" placeholder="Other Amount">
</label>
</div>
Here is the PHP Code that needs to be corrected or added to.
/*** Amount of Donation ***/
$amount = $_POST['amount'];
if (!isset($amount)) {
show_error("Please select a Donation Amount");
}
/*** Amount of Other Donation ***/
$number = check_input($_POST['number']);
setlocale(LC_MONETARY, 'en_US.UTF-8');
money_format('%.2n', $number);
I would really appreciate your help.