0

I have the following code for upload form validation. I'm using jQuery validation plugin.

The required: true works fine, but extension: "csv" is not, and continue with submit.

Here's my code:

<form method="POST" action="uploadCoordenadas" enctype="multipart/form-data" id="frm-upload" name="frm-upload">
  upload file:
  <input type="file" name="file" id="file">
  <br />
  <input type="submit" value="Procesar">
</form>

Javascript:

$(function() {
  $("#frm-upload").validate({
    rules: {
      file: {
        required: true,
        extension: "csv"
      }
    },
    messages: {
      file: {
        required: "Debe seleccionar un archivo para realizar la carga.",
        extension: "Debe seleccionar un archivo con extension valida (*.csv)"
      }
    },
    submitHandler: function(form) {
      form.submit();
    }
  });
});
Sparky
  • 98,165
  • 25
  • 199
  • 285
rvaldesd
  • 15
  • 1
  • 4

1 Answers1

0

You have to include first the additional-methods.js file, because this rule is an extension.

Thomas Lehoux
  • 1,158
  • 9
  • 13