1

We have setup a freeform composer template that has a file upload field, this field is limited to JPEG and PNG filetype only. However we would like to validate the field inline (by default the user is taken to a new page that isn't very informative, just save invalid action).

Basically we want to use the default validation which works fine for required fields, we've tried the following but it doesn't seem to work:

$( "#freeform_cv_upload0" ).rules( "add", {
      extension: "jpeg|png",
      required: true,
      messages: {
        extension: "JPEG or PNG only"
      }
    });

Also tried using standalone jquery validate:

<script type="text/javascript">
jQuery(function ($) {
    $('#request_form').validate({
        rules: {},
        messages: {},
        submitHandler: function () {
            return false
        }
    });

    $( "#freeform_cv_upload0" ).rules( "add", {
      extension: "jpeg|png",
      required: true,
      messages: {
        extension: "JPEG or PNG only"
      }
    });
})
</script>

This works for the required fields, however won't work for the file extension (it still reverts to the ExpressionEngine default of showing the error on a standalone page).

Any ideas?

1
  • I'm interested in this one too, just happen to be working on this today as well!
    – enga
    Jun 16 '14 at 21:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.