1

I have two date start date and end date.once i select start date then end date should not be less then start date.means these date should be disabled to click which less then start date in end date datepicker.

Html

<div class="col-sm-8">
                      <p class="form-control-static">
                        <span editable-bsdate="data.season_start" e-ng-click="openPicker()"  e-is-open="picker.opened" e-datepicker-popup="dd-MMMM-yyyy">{{ (data.season_start | date:"dd/MM/yyyy") || 'empty' }}</span>
                      </p>
 </div>

<div class="col-sm-8">
                      <p class="form-control-static">
                        <span editable-bsdate="data.season_end" e-ng-click="openPicker2()"  e-is-open="picker2.opened" e-datepicker-popup="dd-MMMM-yyyy">{{ (data.season_end | date:"dd/MM/yyyy") || 'empty' }}</span>
                      </p>
 </div>

Angular :

 $scope.picker = {opened: false};
 $scope.openPicker = function (data) {
                    $scope.picker.opened = true;
             });
  };
    $scope.picker2 = {opened: false};
    $scope.openPicker2 = function (data) {
                    $scope.picker.opened = true;
                });
        };

My date picker is working fine.but i want to validate in season_end datepicker as per season_start.thanks

3
  • are you using any libraries? or did you make your own custom date-picker? Did you use the one provided by 'ui-bootstrap' ? Commented Jun 16, 2015 at 6:22
  • no i have used angular-ui.github.io/bootstrap datepicker Commented Jun 16, 2015 at 6:23
  • use the min-date attribute.... after selecting the first date, update minDate variable Commented Jun 16, 2015 at 6:32

1 Answer 1

1

as akashrajkn wrote in the comments above you can simple use the min-date with a scope variable here is an example on how to use min and max dates.plunker

taken from AngularUI Datepicker dynamic date disabling

 <h4>Start</h4>
<div class="form-horizontal">
    <p>
        <input type="text" datepicker-popup="{{format}}" ng-model="start" is-open="startOpened" min="minStartDate" max="maxStartDate" datepicker-options="dateOptions" close-text="Close" />
        <button class="btn" ng-click="openStart()"><i class="icon-calendar"></i></button>
    </p>
</div>
<h4>End</h4>
<div class="form-horizontal">
    <p>
        <input type="text" datepicker-popup="{{format}}" ng-model="end" is-open="endOpened" min="minEndDate" max="maxEndDate" datepicker-options="dateOptions" close-text="Close" />
        <button class="btn" ng-click="openEnd()"><i class="icon-calendar"></i></button>
    </p>
</div>

and in the controller do what it is that you need.

Sign up to request clarification or add additional context in comments.

2 Comments

also $watch will not work in editable bcz it's model name would change on edit
I assume that using xeditable is mandatory for you? so provide a jsfiddle or plunker and we can try to help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.