samedi 18 novembre 2017

Laravel - how to validate sum of values to other input value

i have a form that user enter the amount of cheque and choose the bills that concernded this cheque , so the sum of bills amounts must be equal to cheque's amount .

i have one input for cheque number , one for date of cheque and other for amount of cheque.

i used foreach to generate table of bills with checkbox input in each bill so it return an array of checked values to my controller .

here is my html :

<form method="post" action="" data-parsley-validate class="form-horizontal form-label-left">

                    <div class="form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="num_cheque">N° Chèque <span>*</span>
                                              </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                            <input value="" id="num_cheque" name="num_cheque" class="form-control col-md-7 col-xs-12">                                @if ($errors->has('num_cheque'))
                            <span class="help-block"></span> @endif
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="date_cheque">Date Chèque <span class="required">*</span>
                                              </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                            <input type="text" value="" id="date_cheque" name="date_cheque" class="form-control col-md-7 col-xs-12">                             @if ($errors->has('date_cheque'))
                            <span class="help-block"></span> @endif
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="montant">Montant du Chèque <span class="required">*</span>
                                              </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                            <input value="" id="montant" name="montant" class="form-control col-md-7 col-xs-12">                             @if ($errors->has('montant'))
                            <span class="help-block"></span> @endif
                        </div>
                    </div>

                    <div class="ln_solid"></div>


                    <h3>Selectionner les factures concernés :</h3>
                    <div class="table-responsive">
                        <table class="table table-striped jambo_table bulk_action fact">
                            <thead>
                                <tr class="headings">
                                    <th>

                                    </th>
                                    <th class="column-title">N° Facture </th>
                                    <th class="column-title">N° BL</th>
                                    <th class="column-title">N° BC</th>
                                    <th class="column-title">Region</th>
                                    <th class="column-title">Lieu de livraison</th>
                                    <th class="column-title">Date Facture</th>
                                    <th class="column-title">Montant Total TTC</th>

                                </tr>
                            </thead>

                            <tbody id="tbody">
                                @if(count($factures)) @foreach ($factures as $row)
                                <tr class="even pointer">
                                    <td class="a-center ">
                                        <input type="checkbox" id="fact_id" name="fact_id[]" value="" class="flat">
                                    </td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                </tr>
                                @endforeach @endif
                            </tbody>
                        </table>
                    </div>
                    <div class="ln_solid"></div>

                    <div class="form-group">
                        <div class="col-md-6 col-sm-6 col-xs-12 col-md-offset-6">
                            <input type="hidden" name="_token" value="">
                            <button type="submit" class="btn btn-success">Ajouter</button>
                        </div>
                    </div>
                </form>

what i have to do ?? Can i use jquery ? if yes , how ??



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2zcHlvl
via IFTTT

Aucun commentaire:

Enregistrer un commentaire