Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Sumeet Singhal 20 posts 109 karma points
    Mar 14, 2018 @ 11:11
    Sumeet Singhal
    0

    Upload Field Validation - Formulate

    I am trying to put validation on upload field using regular expression for word & pdf only, regex syntax used from https://stackoverflow.com/questions/374930/validating-file-types-by-regular-expression

    ^.*.(doc|docx|DOC|DOCX|pdf|PDF)$

    If I try to validate it in http://regexstorm.net/tester online tester with my filename its working. But if I use this same syntax in my website its showing error message on button click.

    Any light on this will help, maybe I am going on wrong way. :)

  • Nicholas Westby 2005 posts 6843 karma points c-trib
    Mar 14, 2018 @ 15:43
    Nicholas Westby
    0

    The upload field doesn't respect the regex validation. Feel free to submit a feature request (or bug report, depending on your perspective) here: https://github.com/rhythmagency/formulate/issues

    I won't be working on that anytime soon, but if you have some time perhaps you can submit a pull request. You can read about contributing to Formulate here: https://github.com/rhythmagency/formulate#contributing

    Alternatively, you can create a custom field type, which does not require any modifications to the core of Formulate: http://www.formulate.rocks/articles/custom-field-types

    I am not entirely sure if you'll be able to get the validation working without modifying the core of Formulate, but you might be able to.

  • Sumeet Singhal 20 posts 109 karma points
    Mar 14, 2018 @ 18:39
    Sumeet Singhal
    0

    Very new to Umbraco maybe in future I will do that.

  • Nicholas Westby 2005 posts 6843 karma points c-trib
    Mar 14, 2018 @ 16:20
    Nicholas Westby
    0

    By the way, what I usually do is add a rich text field next to the upload field that explains the files that are acceptable (e.g., "under 4MB, doc or pdf, no images").

  • Sumeet Singhal 20 posts 109 karma points
    Mar 14, 2018 @ 18:36
    Sumeet Singhal
    0

    Its now just to tell them, we have to validate & of course my next point was limiting size of upload.

    Can we achieve both javascript/jQuery or something else?

  • Nicholas Westby 2005 posts 6843 karma points c-trib
    Mar 14, 2018 @ 20:49
    Nicholas Westby
    0

    It seems like detecting the file size should be possible in theory with JavaScript on most modern browsers: https://stackoverflow.com/a/3717847/2052963

    You'd have to integrate that with the frontend of Formulate, which is built with AngularJS.

    This page (also mentioned above) has info changing the frontend of a field, such as the upload field in your case: http://www.formulate.rocks/articles/custom-field-types

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies