form-validate-jquery的多个表单无法正常工作

时间:2017-02-08 12:38:08

标签: php jquery html

在我的laravel项目中,我在同一页面中有3个表单,使用form-validate-jquery类来验证表单元素。但是点击提交按钮,它总是只验证第一个表单。单击第二个表单的提交按钮或第三个表单的提交按钮时有3个表单,它仅显示第一个表单上的验证。

{{ Form::open(array('class' => 'form-horizontal form-validate-jquery','url' => (isset($client_detail)) ? "/clients/$client_id" : "/clients", 'method' => (isset($client_detail)) ? "put" : "post")) }}

            <div class="panel-heading">
                    <h4 class="panel-title">{{ (isset($client_detail)) ? 'Edit' : 'Add' }} Client <a class="heading-elements-toggle"><i class="icon-more"></i></a></h4>
            </div>
            <div class="panel-body">
                <fieldset class="content-group">
                    <legend class="text-bold"></legend>
                        <div class="form-group">
                        <div class="col-md-6">
                        <div class="form-group">
                            <label >Client Name: <span class="text-danger">*</span></label>
                            <div class="input-group">
                                    <span class="input-group-addon"><i class="icon-user"></i></span>
                                    {{ Form:: text('client_name', $client_name, array('class' => 'form-control', 'required' => '', 'placeholder' => 'name', 'maxlength' => '50')) }}
                            </div>            
                        </div>
                    </div>
                        <div class="col-md-3">
                        <div class="form-group">
                            <label >Client Code: <span class="text-danger">*</span></label>
                           @if(isset($client_detail)) <div><mark>{{$client_code}}</mark></div> @else {{ Form:: text('client_code', $client_code, array('class' => 'form-control', 'required' => '','placeholder' => 'Code', 'maxlength' => '10')) }}@endif
                        </div>
                        </div>
                        <div class="col-md-3">
                        <div class="form-group">
                            <label>Exchequer Code: <span class="text-danger">*</span></label>
                           @if(isset($client_detail))<div><mark>{{$exchequer}}</mark></div> @else {{ Form:: text('exchequer', $exchequer, array('class' => 'form-control', 'required' => '','placeholder' => 'Exchequer', 'maxlength' => '10')) }}@endif
                        </div>
                        </div>
                        </div>

                        <div class="form-group">
                        <div class="col-md-4">
                         <div class="form-group">
                            <label >Address1: <span class="text-danger">*</span></label>
                            {{ Form:: text('address1', $address1, array('class' => 'form-control','placeholder' => 'Address1', 'maxlength' => '50')) }}</div>
                        </div>
                        <div class="col-md-4">
                        <div class="form-group">
                            <label >Address2:</label>
                            {{ Form:: text('address2', $address2, array('class' => 'form-control','placeholder' => 'Address2', 'maxlength' => '50')) }}</div>
                        </div>
                        <div class="col-md-4">
                        <div class="form-group">
                            <label >Address3:</label>
                           {{ Form:: text('address3', $address3, array('class' => 'form-control','placeholder' => 'Address3', 'maxlength' => '50')) }}</div>
                        </div>
                        </div>
                        <div class="form-group">
                        <div class="col-md-4">
                        <div class="form-group">
                            <label>Town: <span class="text-danger">*</span></label>
                           {{ Form:: text('town', $town, array('class' => 'form-control', 'required' => '','placeholder' => 'Town', 'maxlength' => '10')) }}</div>
                        </div>
                        <div class="col-md-4">
                        <div class="form-group">
                            <label >Country:</label>
                            <div class="input-group">
                                    <span class="input-group-addon"><i class="icon-earth"></i></span>
                                    {{ Form:: text('country', $country, array('class' => 'form-control', 'placeholder' => 'Country', 'maxlength' => '10')) }}</div>
                            </div>
                        </div>
                        <div class="col-md-4">
                        <div class="form-group">
                            <label >Postcode: <span class="text-danger">*</span></label>
                            {{ Form:: text('postcode', $postcode, array('class' => 'form-control', 'required' => '','placeholder' => 'Postcode', 'maxlength' => '8')) }}</div>
                        </div>
                        </div>
                        <div class="form-group"> 
                        <div class="col-md-4">
                        <div class="form-group">
                            <label >Contact Name: <span class="text-danger">*</span></label>
                           {{ Form:: text('contact_name', $contact_name, array('class' => 'form-control', 'required' => '','placeholder' => 'contact Name', 'maxlength' => '20')) }}</div>
                        </div>
                        <div class="col-md-4">
                        <div class="form-group">
                            <label >Contact Number: <span class="text-danger">*</span></label>
                            {{ Form:: number('contact_number', $contact_number, array('class' => 'form-control', 'required' => '','placeholder' => 'contact Number', 'maxlength' => '10')) }}</div>
                        </div>
                        </div>
                        <div class="form-group">
                        <div class="col-md-12">
                        <div class="form-group">
                            <label >Comment:</label>
                           {{ Form:: text('comment', $comment, array('class' => 'form-control','placeholder' => 'Comment', 'maxlength' => '500')) }}</div>
                        </div>
                        </div>
                        <div class="form-group">
                        <div class="col-md-2">
                        <div class="form-group">
                            <label >Status: <span class="text-danger">*</span></label>
                            {{ Form:: checkbox('status', 'A', ($status=='A')?'1':null,array('id' => 'status', 'class' => 'switch','data-on-text'=>'Yes','data-off-text'=>'No')) }}

                           <!-- {{ Form::select('status', [
                                '' => 'Select',
                                'A' => 'Active',
                                'I' => 'Inactive'],$status,array('class' => 'form-control','required' => '')
                             ) }}--></div>
                        </div>
                    </fieldset>


            </div>
            <div class="panel-heading">
                    <h4 class="panel-title">Contracts <a class="heading-elements-toggle"><i class="icon-more"></i></a></h4>
            </div>
            <div class="panel-body">
                    <fieldset class="content-group">
                    <legend class="text-bold"></legend>
                    <table id="contract_table" class="table" style="width:100%" cellspacing="10px">
                    <thead>
                        <?php 
                        $addModel = 'showAddContractModel_create()';
                        if(isset($contract_detail))
                        {
                            $addModel = "showAddContractModel_edit($client_id)";
                        }
                        ?>
                        <tr>
                        <th>Contract Name<span class="text-danger">*</span></th><th>Contract Code<span class="text-danger">*</span></th><th>Contract Type</th><th>Contract Extension Period<span class="text-danger">*</span></th><th>Contract Email<span class="text-danger">*</span></th><th>Start Date<span class="text-danger">*</span></th><th>End Date</th><th><a href="javascript:void(0);" name="removebutton" onclick="{{ $addModel }}" class="btn bg-info-300">+Add Contract</a></th>
                        </tr>
                    </thead>
                    <tbody>
                    @if(isset($contract_detail))
                        @if(count($contract_detail))
                            @php ($i=0)
                            @foreach($contract_detail as $contract)
                            @php ($i++ )
                            <tr>
                            <td><input type="hidden" id="hid_contract_id_{{ $contract->id }}" name="contract_id[]" value="{{ $contract->id }}"><input type="hidden" id="hid_contract_name_{{ $contract->id }}" name="contract_name[]" value="{{ $contract->contract_name }}" ><span  id='contract_name_{{ $contract->id }}'>{{ $contract->contract_name }}</span></td>
                            <td><input type="hidden" id="hid_contract_code_{{ $contract->id }}" name="contract_code[]" value="{{ $contract->contract_code }}"  ><span  id='contract_code_{{ $contract->id }}'>{{ $contract->contract_code }}</span></td>
                            <td><input type="hidden" id="hid_contract_type_{{ $contract->id }}" name="contract_type[]" value="{{ $contract->contract_type }}"><span  id='contract_type_{{ $contract->id }}'>{{ $contract->contract_type }}</span></td>
                            <td><input type="hidden" id="hid_contract_ext_period_{{ $contract->id }}" name="contract_ext_period[]" value="{{ $contract->contract_ext_period }}"  ><span  id='contract_ext_period_{{ $contract->id }}'>{{ $contract->contract_ext_period }}</span></td>
                            <td><input type="hidden" id="hid_contract_email_{{ $contract->id }}" name="contract_email[]" value="{{ $contract->contract_email }}"  ><span  id='contract_emil_{{ $contract->id }}'>{{ $contract->contract_email }}</span></td>
                            <td><input type="hidden" id="hid_startdate_{{ $contract->id }}" name="startdate[]" value="{{ \Carbon\Carbon::parse($contract->startdate)->format('d-m-Y') }}"  ><span  id='startdate_{{ $contract->id }}'>{{ \Carbon\Carbon::parse($contract->startdate)->format('d-m-Y') }}</span></td>
                            <td><input type="hidden" id="hid_enddate_{{ $contract->id }}" name="enddate[]" value="{{ \Carbon\Carbon::parse($contract->enddate)->format('d-m-Y') }}"><span  id='enddate_{{ $contract->id }}'>{{ \Carbon\Carbon::parse($contract->enddate)->format('d-m-Y') }}</span></td>
                            <td><div class="heading-btn-group">
                            <a href="javascript:void(0);" name="removebutton" onclick="showContractEditModel_edit({{ $contract->id }},'edit')"><i class="icon-pencil7 text-info"></i></a>
                            <a href="javascript:;" name="removebutton" onclick="removeContractRow(this,{{ $contract->id }},'{{ $contract->contract_name }}')" ><i class="icon-trash  delete text-danger"></i></a>
                        </div></td>
                        <td><div class="heading-btn-group">
                            <a href="javascript:;" name="addresponse" onclick="showResponse('{!! URL::to('/showResponse') !!}','{{$contract->id}}')" class="btn bg-indigo-300">+</a>
                        </div></td>
                            </tr>

                            @endforeach
                            @else
                            <tr>
                                <td colspan='8' class='text-center'>No data found.</td>
                            </tr>
                        @endif    
                    @endif
                    </tbody>
                        </table>
                    </fieldset>
                        <div class="text-right">
                            <button type="reset" class="btn btn-default" id="reset">Reset<i class="icon-reload-alt position-right"></i></button>
                            <button type="submit" class="btn btn-custom">Submit<i class="icon-arrow-right14 position-right"></i></button>
                        </div>
            </div>


{{ Form::close() }}

{{ Form::open(array('class' => 'form-horizontal form-validate-jquery','id' => 'add_response_form')) }}
            {{ Form:: hidden('contract_id', "",array("id"=>"contract_id"))  }}
            <div class="modal-body" id="showResponse_body">
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-sm btn-primary" id="item-add-btn" data-resource="faq" onclick="add_response('{{URL::to('/updateResponse')}}')" >Submit</button>
                <button type="button" class="btn btn-sm btn-default" data-dismiss="modal">Cancel</button>
            </div>
            {{ Form::close() }}

{{ Form::open(array('class' => 'form-horizontal form-validate-jquery','id' => 'add_item_form')) }}
            <div class="modal-body">
                <fieldset class="content-group">
                        <legend class="text-bold"></legend>
                        <div class="form-group">
                            <label class="control-label col-lg-3">Contract Name:  <span class="text-danger">*</span></label>
                            <div class="col-lg-9">
                                <div class="input-group">
                                        <span class="input-group-addon"><i class="icon-user"></i></span>
                                {{ Form:: text('contract_name', '', array('id' => 'contract_name', 'class' => 'form-control', 'placeholder' => 'Contract Name','required' => 'required')) }}
                                </div>
                            </div>    
                        </div>
                        <div class="form-group">
                            <label class="control-label col-lg-3">Contract Code: <span class="text-danger">*</span></label>
                            <div class="col-lg-9">
                                {{ Form:: text('contract_code', '', array('id' => 'contract_code', 'class' => 'form-control', 'placeholder' => 'Contract Code','required' => 'required')) }}
                            </div>    
                        </div>
                        <div class="form-group">
                            <label class="control-label col-lg-3">Contract Type: </label>
                            <div class="col-lg-9">
                                {{ Form:: select('contract_type',  [
                                                '' => 'Select',
                                                'A' => 'A',
                                                'B' => 'B'],'',array('id'=>'contract_type', 'class' => 'form-control','title'=>'Please fill out this field')) }}
                            </div>    
                        </div>                        
                        <div class="form-group">
                            <label class="control-label col-lg-3">Contract Extension Period: <span class="text-danger">*</span></label>
                            <div class="col-lg-9">
                                {{ Form:: text('contract_ext_period', '', array('id' => 'contract_ext_period', 'class' => 'form-control', 'placeholder' => 'Contract Extension Period','required' => 'required')) }}
                            </div>    
                        </div>
                        <div class="form-group">
                            <label class="control-label col-lg-3">Contract Email: <span class="text-danger">*</span></label>
                            <div class="col-lg-9">
                                <div class="input-group">
                                        <span class="input-group-addon"><i class="icon-mail-read"></i></span>
                                        {{ Form:: email('contract_email', '',array('id' => 'contract_email', 'class' => 'form-control', 'placeholder' => 'Contract Email','required' => 'required')) }}
                                </div>        
                            </div>    
                        </div>
                        <div class="form-group">
                            <label class="control-label col-lg-3">Start Date:  <span class="text-danger">*</span></label>
                            <div class="col-lg-9">
                                <div class="input-group">
                                        <span class="input-group-addon"><i class="icon-calendar3"></i></span>
                                        {{ Form:: text('startdate', '',array('id' => 'startdate', 'class' => 'form-control datepicker', 'placeholder' => 'Start Date','required' => 'required')) }}
                                </div>        
                            </div>    
                        </div>                        
                        <div class="form-group">
                            <label class="control-label col-lg-3">End Date:  <span class="text-danger">*</span></label>
                            <div class="col-lg-9">
                                <div class="input-group">
                                        <span class="input-group-addon"><i class="icon-calendar3"></i></span>
                                        {{ Form:: text('enddate', '', array('id' => 'enddate', 'class' => 'form-control datepicker', 'placeholder' => 'End Date','required' => 'required')) }}
                                </div>        
                            </div>    
                        </div>
                </fieldset>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-sm btn-primary" id="contract-add-btn" data-resource="faq" onclick="setContractModelToTable(1,'add');" >Add</button>
                <button type="button" class="btn btn-sm btn-default" data-dismiss="modal">Cancel</button>
            </div>
            {{ Form::close() }}

0 个答案:

没有答案