0

I have a form with two upload input.

<form action="http://localhost/royalshop/administrator/submit_product" method="post" accept-charset="utf-8" id="myform" enctype="multipart/form-data">  
  <div class="productpicstables">
    <input type="file" name="file1" />
  </div>
  <div class="productpicstables">
    <input type="file" name="file2" />
  </div>
</form>

I want to validate just the first one with jQuery. How can I do this?

It should be required and better to have size of 512*512.

Thanks.

2
  • close and format tags nesting Commented Mar 10, 2015 at 10:22
  • If this question is not about the jQuery Validate plugin, then please do not use that tag. Otherwise, make an attempt and show the relevant code. Thanks. Commented Mar 10, 2015 at 14:40

1 Answer 1

2

use the same name:

$('input[type="file"]').each(function() {
var $this = $(this);
if ($this.val() == '') { 
    Response('- Upload file not selected!', true);
    $this.addClass('Error').fadeOut().fadeIn();
    return false;
} else {
    $this.removeClass('Error');
}

});

Sign up to request clarification or add additional context in comments.

1 Comment

Before I ask, I searched and found this. Any way I solved. Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.