0

フォームがリロードさbootstrapvalidatorれていないとき。初めてフォームを送信したときは正常に機能していますが、クリックしてレコードを追加すると機能しません。

HTMLフォームは...

<form class="clearfix"  role="form" class="form-horizontal" id="upload-resume-form" method="post" enctype="multipart/form-data">
 <div class="col-sm-7 col-md-7  mar-bot-min2">
     <input type="text" class="form-control" placeholder="Resume Title" name="name"/>
  </div>
  <div class="col-sm-7 col-md-7  mar-bot-min2">
      <input type="text" class="form-control" placeholder="Upload resume" id="resume_name"  / >
   </div>
   <div class="col-sm-4 col-md-4  mar-bot-min2">
       <a class="btn _btn  blu-blu-lg browse-btm">Choose File</a>
                            <div class="hid-brow-btn">
                                <input type="file" name="resume_file" id="resume_file" />       
                            </div>
                        </div>
      <div class="col-xs-12 col-sm-12 col-md-12 mar-bot-min2 buttongroup">
      <button type="button" class="btn _btn gr-drk" data-bind="click:uploadResume"><i class="fa fa-save fa-fw"></i>Save</button>
       <button type="button" class="btn _btn gr-drk " data-bind="click: cancelResume"><i class="fa fa-ban fa-fw"></i>Cancel</button>
    </div>
</form>

JS コード

$(document).ready(function(){
 $('#upload-resume-form').bootstrapValidator({
  feedbackIcons: {
        valid: 'glyphicon glyphicon-ok',
        invalid: 'glyphicon glyphicon-remove',
        validating: 'glyphicon glyphicon-refresh'
    },
    fields: {
       name: {
            validators: {
                notEmpty: {
                    message: 'Resume title is required'
                },
                regexp: {
                regexp: /^[A-Za-z\s.'-]+$/,
                message: "Alphabetical characters, hyphens and spaces"
            }
            }
        },

        resume_file: {
            validators: {
                notEmpty: {
                    message: 'Resume file is required' 
                },
                file: {
                    extension: 'doc,docx,pdf,rtf,txt,ppt,pptx',
                    type: 'application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/pdf,application/x-download,application/x-pdf,application/acrobat,applications/vnd.pdf,text/pdf,text/x-pdf,application/rtf,text/plain,application/vnd.ms-powerpoint,application/powerpoint,application/mspowerpoint,application/vnd.ms-office,application/vnd.openxmlformats-officedocument.presentationml.presentation',
                    maxSize: 11000000, 
                    message: 'The selected file is not valid, it should be (doc, docx, pdf, rtf, txt, ppt, pptx) and not more than 10MB in size'
                }
            }   
        }   
    }
})

.........

self.doAddResume = function(){            
        $('input[name=name]').val('');
        $('#resume_file').wrap('<form>').closest('form').get(0).reset();
        $("#resume_name").val('');
        self.showResumeForm(true);
    }
4

0 に答える 0