在使用DropZone上传文件之前验证必填字段

时间:2018-05-31 10:32:54

标签: javascript c#

<div id="div1" class="row">
        <section class="col col-12 col-lg-6">
            <label class="control-label">First Name:</label>
            <input type="text" class="form-control" id="txtfirstname" placeholder="First Name" name="firstname" />
        </section>
        <section class="col col-12 col-lg-6">
            <label class="control-label">Middle Name:</label>
            <input type="text" class="form-control" id="txtmiddlename" placeholder="Middle Name" name="middlename" />
        </section>
    </div>
    <div id="div2" class="row">
        <section class="col col-12 col-lg-6">
            <label class="control-label">Last Name:</label>
            <input type="text" class="form-control" id="txtlastname" placeholder="Last Name" name="lastname" />
        </section>
        <section class="col col-12 col-lg-6">
            <label class="control-label">Date Of Birth:</label>
            <input type="date" class="form-control" id="DOB" />
        </section>
    </div>

这是我的Html元素,它是用户使用DropZone上传文件之前的必填字段。

Dropzone.options.dropzoneForm = {
            maxFiles: 50,
            acceptedFiles: 'image/jpeg,image/png,image/tiff,application/pdf,.pdf,.jpeg,.jpg,.tiff,.tif,.pdf',
            init: function () {
                this.on("maxfilesexceeded", function (data) {
                    var res = eval('(' + data.xhr.responseText + ')');

                });
                this.on("success", function (file, response) {
                    debugger
                    var dicom = $("input[name='optdicomimg']:checked").val();
                    var details = {
                        FirstName: $('#txtfirstname').val(),
                        MiddleName: $('#txtmiddlename').val(),
                        LastName: $('#txtlastname').val(),
                        DateOfBirth: $('#DOB').val(),
                        Gender: $("input[name='optradio']:checked").val(),
                        EmailID: $('#txtemailid').val(),
                        MobileNumber: $('#txtmobilenumber').val(),
                        //StudyUID: ID,
                        MRNNumber: $('#txtmrnnumber').val()
                    }

                    var data = JSON.stringify(details)
                    savePatientData(data, dicom);
                });
            }
        };

以上是我的dropzone JavaScript代码。 请任何人帮助我如何在用户上传之前进行验证。 提前致谢

0 个答案:

没有答案