3

My form in NOT asynchronised. I want file input to be required. If I add "required" attribute in that input it show popup required message even if file is uploaded. If I ommit "required" attribute and define validation in kendoUpload configuration to "minFileSize: 1" it only react after file is uploaded, but ignoring that validation if form is submited.

    <form method="post" action="foo" enctype="multipart/form-data" id="document-form">
        <div class="modal-body">
                <input id="files" type="file" name="files" required/>
                <input name="description" required/>
        <div class="modal-footer">
            <button type="submit" class="k-button">Dodaj</button>
        </div>
    </form>

$('#files').kendoUpload(
  {
    multiple: false,
    validation: {
      minFileSize: 1
    }
  }
)
Sruj
  • 1,177
  • 2
  • 18
  • 38

1 Answers1

0

do not use "required" attribute, use other attribute such as validationMessage

you can use this rule:

 rules: {
    upload: function(input) {
    if (input[0].type == "file" && input.is("[validationMessage]")) {
    var len = input.closest(".k-upload").find(".k-file").length;
    return len > 0;
    }
    return true;
    }
Mamad4D
  • 1
  • 1