Copied to clipboard

Flag this post as spam?

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


  • Hash 2 posts 22 karma points
    Dec 02, 2011 @ 12:12
    Hash
    0

    Custom validation in umbraco

    In Umbraco, I have a document which is having 3 properties. Out of 3 two of them are mandatory, so i checked the mandatory checkbox in property tab. When i click save and publish the document is published without showing any validation errors.

    But for the last property, I am looking to create a custom validation as here I need to check whether that property is having value in it, if it has then validation should fail. I cannot use mandatory checkbox as this checks for value presence.

    Any suggestions?

  • Bo Damgaard Mortensen 719 posts 1207 karma points
    Dec 03, 2011 @ 17:26
    Bo Damgaard Mortensen
    0

    Hi Hash,

    Just out of interest: why would you want a field to be empty at all times in Umbraco? :-)

    - Bo

  • Keyur Shah 14 posts 44 karma points
    Oct 09, 2014 @ 07:05
    Keyur Shah
    0

    I am also looking something similar.

    I have propery call "umbracoUrlName".

    On click of save and publish I would like to check the uniqueness of its value for Url Name on same document type.

    If the "umbracoUrlName" is unique it will save and publish.

    If not then It will display some custome message in umbraco back office.

    Is it possible to achieve and how?

    Or any better way to do it.

     

    Thanks

    -Keyur

     

  • Dave Woestenborghs 3504 posts 12133 karma points MVP 8x admin c-trib
    Oct 09, 2014 @ 07:40
    Dave Woestenborghs
    0

    You can hook in on the saving event of your document and do your validation there. When the validation fails you can cancel the saving.

    More information on hooking in to the contentservice events can be found here : http://our.umbraco.org/documentation/Reference/Events-v6/

    Dave

  • Keyur Shah 14 posts 44 karma points
    Oct 09, 2014 @ 07:58
    Keyur Shah
    0

    Hi Dave,

    Thanks for quick response I will try it and let you know and can we set custom message over there to show it in back office ?

    Thanks,

  • Keyur Shah 14 posts 44 karma points
    Oct 09, 2014 @ 14:16
    Keyur Shah
    0

    Hi Dave,

    I have achieved the way you suggested but struggling to show speech bubble(custome message).

    Thanks,

  • Dave Woestenborghs 3504 posts 12133 karma points MVP 8x admin c-trib
    Oct 09, 2014 @ 15:59
    Dave Woestenborghs
    0

    I actually haven't figured that one out. Yet in v4 it was possible to set the speechbublle...But since v6 and the introduction of the new API I haven't got it to work (yet).

    Dave

Please Sign in or register to post replies

Write your reply to:

Draft