1

Here is my code

<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://jquery.bassistance.de/validate/jquery.validate.js"></script>
<script src="http://jquery.bassistance.de/validate/additional-methods.js"></script>
<script>
   $(document).ready(function () {
   $('#uploled_file').validate({
       rules: {
                 extension: "xls|csv"
              }
       });
   });
</script>

and the form tag---

<form name="exportar_archivo_plano" id="exportar_archivo_plano" action="exportar_archivo_plano_action.php" method="post" enctype="multipart/form-data">
     <fieldset class="fieldsetspacer">
             <legend><span>Exportar Archivo Plano</span></legend>
                     <table width="40%" border="0">
                                    <tr></tr>
                                    <tr><div class="upload-error"></div></tr>
                                    <tr>
                                        <td><label for="fecharegistro">Seleccionar el Archivo</label></td>
                                        <td>
                                            <input type="file" name="uploled_file" id="uploled_file" style="width: 200px;" />
                                        </td>
                                    </tr>
                                    <tr>
                                        <td></td>
                                        <td>
                                            <input type="submit" name="uploled_submit" id="uploled_submit" value="Subir"/>
                                        </td>
                                    </tr>
                                </table>
                            </fieldset>
                        </form>

My ERROR :- form is simply submitted without validating of file.

1 Answer 1

2

That's not an error. Validate the form element instead of the input:

$('#exportar_archivo_plano').validate({
    rules: {
       // Targeting form fields
       uploled_file: {
         // required: true,
         extension: "xls|csv"
       } 
    },
    submitHandler: function() {
       // Submit the form when validation passes
       this.submit();
    }
});
Sign up to request clarification or add additional context in comments.

1 Comment

Hello, I just added <input type="hidden" name="formId" id="formId" value="<?=$_REQUEST['form_id'];?>" /> before submit button and it does not working now..can you give me solution?

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.