1
0
-1

Hello Master,

I have one form called form A, in this activity user need to keyin the arrival date using the date picker field. From the arrival date i want to add more 90days as my warranty date(hidden field). Can this be done at the same form? Any advise?

Thanks in advance.

    CommentAdd your comment...

    1 answer

    1.  
      1
      0
      -1

      Hi, u will need to do some javascript for this. By refer to Limit Date Range for "From Date" & "To Date" Date Picker Fields & Javascript API#FormUtil. I wrote the following script for ur reference. U will need to put this script in a Custom HTML field in ur form.

      <script>
           $(document).ready(function(){
                var dateField = FormUtil.getField("dateField");
                var hiddenField = FormUtil.getField("hidden");
                var updateDueDate = function (field, selectedDate) {
                     console.log($(field));
                     console.log($(dateField));
                     if ($(field).attr("id") === $(dateField).attr("id")) {
                         var instance = $(field).data( "datepicker" );
                         var date = $.datepicker.parseDate(instance.settings.dateFormat || $.datepicker._defaults.dateFormat, selectedDate, instance.settings );
                         date.setDate(date.getDate() + 90);
                         var dateString = $.datepicker.formatDate(instance.settings.dateFormat, date, instance.settings);
                         $(hiddenField).val(dateString);
                     }
                };
                $.datepicker.setDefaults({
                      onSelect: function( selectedDate ) {
                              updateDueDate(this, selectedDate);
                      }
                });
           });
      </script>

       

       

        CommentAdd your comment...