Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

Only first file input is validated. Any suggestions how to fix this? I tried with the .each, like suggested somewhere, but it still doesnt work.

Demo:

HTML:

<form method="post" action="<?php echo $_SERVER['PHP_SELF']."?".$_SERVER["QUERY_STRING"]; ?>" enctype="multipart/form-data" id="fnpMain">
<table class="ConTable">
<tr>
<td>Photo 1:</td>
<td> <input type="file" class="ipfile" name="pic[]" /> </td>
</tr>
<tr>
<td>Photo 2:</td>
<td> <input type="file" class="ipfile" name="pic[]" /> </td>
</tr>
<tr>
<td>Photo 3:</td>
<td> <input type="file" class="ipfile" name="pic[]" /> </td>
</tr>
</table>
<input type="submit" name="sub" value="submit" />
</form>

JQ:

<script type="text/javascript">
  $(document).ready(function(){

    $("#fnpMain").validate(
    {
    rules:{
        Telefon:{required:true, exactlength:9, digits:true}
    }
    });

    $("input[type=file]").each(function(){
       $(this).rules("add", {
           required:true, 
           accept: "jpe?g"
       });                    
    });

  });
</script>
share|improve this question

closed as not a real question by Kev Jun 4 '12 at 0:24

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

add comment