x First time here? Check out the FAQ
  • Avatar34posts54karma

    from - to date validation ?

    Mo started this topic June 8, 2010 @ 09:46

    I'm a few hours away from a project deadline and failed to consider this:

    How can I implement validation for date period where two datepicker fields are concerned?

    e.g: from date should not be later than to date

     

    any help would be GREATLY appreciated! :D


  • Avatar1771posts1777karma
    adminComment with ID: 35524
    Morten Bock posted this reply June 8, 2010 @ 10:03

    Hmm, I don't think there is any built in way to handle this.

    I have done something similar by adding a custom datatype to the document type. The datatype was a usercontrol with a validator control on it. When the document is saved, you usercontrol will get called, and you can do some coding logic to add errors to the validator, which will cause umbraco to prompt the user to correct the error before publishing.


  • Avatar34posts54karma
    Comment with ID: 35526
    Mo posted this reply June 8, 2010 @ 10:46

    oh no...

     

    I am stuck, no way can I put together a bug free user control in time :(


  • Avatar34posts54karma
    Comment with ID: 35530
    Mo posted this reply June 8, 2010 @ 11:14

    sorry morten but what do you mean by publishing? My question is in regards to contour forms and not pages (?)


  • Avatar1771posts1777karma
    adminComment with ID: 35532
    Morten Bock posted this reply June 8, 2010 @ 11:38

    Ah, so sorry. I did not see the forum category the question was posted in.

    I'm afraid I have no experience with contour. :-/


  • Avatar207posts248karma
    Comment with ID: 35585
    Harald Ulriksen posted this reply June 9, 2010 @ 12:04

    Mo,

    I suggest adding a javascript to handle this validation.

    You could also inherit or wrap the contour renderform.ascx and alter the validations if you need serverside validation as well.

    Cheers,
    Harald.


  • Avatar34posts54karma
    Comment with ID: 36458
    Mo posted this reply June 20, 2010 @ 06:30

    I actually need a solution which does not need to be implemented manually for every new form, as the client requires that form management be handed to their (non-developer) staff. Any suggestions?


  • Avatar207posts248karma
    Comment with ID: 36505
    Harald Ulriksen posted this reply June 21, 2010 @ 09:25

    Then I think you're back to adding a custom fieldtype to store the two date values. However, both values will then be stored in one field in the record. This might be fine depending on their use of the collected data.

    Another option is to tell them that from/to dates fields MUST use some foo and bar as label. You can then write a javascript to handle this, but if they want a different field label your're stuck. 

    Hth,
    Harald


Please login or Sign up To post replies