This is a migrated thread and some comments may be shown as answers.

validator not working with @Html.TextBoxFor

1 Answer 109 Views
Upload
This is a migrated thread and some comments may be shown as answers.
Jeet
Top achievements
Rank 1
Jeet asked on 10 Oct 2012, 01:09 PM
Hello,

JS
$(document).ready(function () {
 
       var validator = $("#tickets").kendoValidator({
           rules: {
               upload: function (input) {
                   if (input[0].type == "file") {
                       return input.closest(".k-upload").find(".k-file").length;
                   }
                   return true;
               }
           }
       }).data("kendoValidator");
 
 
       $("button").click(function (e) {
 
           if (!validator.validate()) {
               e.preventDefault();
           }
       });
   });
$("#fuActivitySheet").kendoUpload({
       multiple: false
   });


Cshtml
<div id="tickets">
@using (Html.BeginForm("UploadNewSheet", "Vendor", FormMethod.Post, new { id = "UploadSheet", enctype = "multipart/form-data" }))
{
        @Html.TextBoxFor(model => model.UploadedFile, new { id = "fuActivitySheet", name="fuActivitySheet" , type = "file" })
 
<br />
 
<button class="k-button" type="submit">Submit</button>
}
</div>

Model
[Display(Name = "Sheet: ")]
      [Required(ErrorMessage = "Please Select sheet to upload")]
      public System.Web.HttpPostedFileBase UploadedFile { get; set; }




Thanks,
Jeet bhatt

1 Answer, 1 is accepted

Sort by
0
Accepted
Jayesh Goyani
Top achievements
Rank 2
answered on 20 Oct 2012, 09:59 AM
Hello,

Please try with below link.

http://jayeshgoyani.blogspot.in/2012/10/validate-upload-control-in-kendoui.html

Thanks,
Jayesh Goyani
Tags
Upload
Asked by
Jeet
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Share this question
or