i have an checkbox in my blade where users can enable an other Payment method and now i want if someone check this box, the price is required for this Payment method.
Checkbox Blade
<div class="form-group">
<label for="accept1">
<img src="/img/accept1.png">
Accept other payment method
</label>
<input type="checkbox" value="true" name="accept1"> Yes
</div>
Price Blade
<div class="form-group">
<label for="newprice"><img src="/img/newprice.png"> New</label>
<input type="number" step="any" name="newprice" value="{{old('newprice')}}">
</div>
Controller
<?php
if ($request->accept1 == 'true') {
$product->accept1 = true;
}
if ($request->newprice == 'true') {
if (!is_numeric($request->newprice) || $request->newprice <= 0.0001) {
session()->flash('errormessage', ' Price is required');
return redirect()->back()->withInput();
}
}
If someone clicks the checkbox now, they must also enter a price or they get an error message.
How can I change the code to make it work?