Copied to clipboard

Flag this post as spam?

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


  • Jonas Eriksson 930 posts 1825 karma points
    Dec 07, 2010 @ 09:37
    Jonas Eriksson
    0

    Custom validation on document save

    I need to make a custom validation for documents (something like property1.value>property2.value). I come to think of two options:

    1) hook up to the save event and check the properties serverside. But can I send a validation message from there to the UI?

    2) perform validation with a jQuery-hack.

    3) make a custom data type (I'd rather not since I like the straight forward way of getting plain property data from nodes).

    Any thoughts about this?

    Thanks!

    / Jonas

     

  • Hendy Racher 863 posts 3849 karma points MVP 2x admin c-trib
    Dec 07, 2010 @ 09:51
    Hendy Racher
    0

    Hi Jonas,

    I'm very interested as to how best to solve this too. Previously I've used your first suggestion by way of an event handler on BeforePublish, and returning any validation descriptions in the baloon popup, but this was far from ideal, so ended up building a self contained datatype with all the fields to be validated together.

    I'm not sure how a custom datatype could work, unless it did it's work client side, but then it'd have to know the inner workings of the other types to be validated.

    Cheers,

    Hendy

  • Jonas Eriksson 930 posts 1825 karma points
    Dec 07, 2010 @ 10:01
    Jonas Eriksson
    0

    Hi Hendy, thanks for your input

    1) I see. Yeah the good ol' balloon... 

    3) Custom - just a datatype that includes all the necessary inputs, and by so having full control over them. But then again - the individual prop values would need some extra parsing using them later on.

    Perhaps a custom "javascript datatype" that simply renders a js defined in the documenttype, and that one will have the client side (jQuery) validation code. (hackish)

    Cheers,

    Jonas

     

Please Sign in or register to post replies

Write your reply to:

Draft