CA Service Management

 View Only
  • 1.  Date Validation in SC Form

    Posted Apr 21, 2016 02:41 PM

    Hi guys,

         I have a form in wich i have two dates (start_date and end_date),  i'm trying to validate that the end_date is grater than start_date after the end_date is selected. So i have created a script:


       x : function() {

           if (end_date < start_date)

            alert('End date must be grater than Start date');




    So i call the function this way:  ca_fd.js.x(). But when i try to call the function from the attribute OnValidate in the Date property form i can't save it. So i have some questions:

    1. In my if statement "if (end_date < start_date)", how should i reference the atributes ids for end_date and start_date?

    2. Where should i place my function to execute, in other what property should i call it? (Onvalidate,OnkeyUp, etc)

    3. How can i validate this and prevent to submission of the form if end_date does is lower than start_date.

    4. Is there any way to not show lower values in end_date considering the start_date selected?


    Let me know if you have any questions about this post.


    Thanks in advance guys!

  • 2.  Re: Date Validation in SC Form
    Best Answer

    Posted Apr 21, 2016 04:02 PM

    One way to go about this could be to specify something similar to the following for the start_date field:


    onChange: ca_fdSetDateFieldMinValue(ca_fd.formId,'end_date',ca_fdGetDateFieldValueInMillis(ca_fd.formId,'start_date'));

  • 3.  Re: Date Validation in SC Form

    Posted Apr 21, 2016 04:37 PM

    I have applied this to the start_date in OnChange property replacing ca_fd.formId value but did not work...did i missed something?

  • 4.  Re: Date Validation in SC Form

    Posted Apr 21, 2016 05:26 PM

    No need to replace ca_fd.formId (this variable references the _id of the form) just ensure the _id of your date fields are start_date and end_date. Also this functionality will not work from form designer, so you will need to associate the form to an offering and then test from Home > Requests.


    After selecting the start date the minimum value of the end date will be set to the value of the start date, so all dates prior will be grayed out.

  • 5.  Re: Date Validation in SC Form

    Posted Apr 22, 2016 11:31 AM

    Thanks a lot Jason! it worked with just ca_fd.formId!


    Very Helpful


    Best Regards!

  • 6.  Re: Date Validation in SC Form

    Posted Apr 22, 2016 11:58 AM

    You are most welcome, glad it helped!