Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
790
dates validate
posted

Hello,

I have 2 igDatePicker in my page. 

I want to validate that 1st datepicker value is not larger then 2nd datepicker value , and the oposite.

Also the validator need to be updated when i change one of the datepickers .

For example-

date picker 1 - 01/01/2015

date picker 2 - 01/01/2016

if i change datepicker 1 to 10/01/2015 , than datepicker 2 value can't be before than date.

How can i do it? by the way , i am using angularjs

Parents
No Data
Reply
  • 2671
    Suggested Answer
    Offline posted

    Hello Michael,

     

    You can also do custom validation similar to what is shown in this thread:

    https://github.com/IgniteUI/igniteui-angular/issues/37

    $scope.myValidator = function(value) {

          console.log('called myValidator');

          this.options.errorMessage = "Date must be before " + $scope.minDate.toLocaleDateString();

          return value < $scope.minDate;

        }

    <ig-date-picker class="form-control" id="endDate" ng-model="input.end">

          <validator-options custom='{{myValidator}}'></validator-options>

        </ig-date-picker>

    (Please note my update about versions)

     

    That sample can be easily updated to just bind another picker to the minDate like so:

    http://jsfiddle.net/damyanpetev/3gdo43sk/

     

    Does this help? It’s just one editor not larger than the first but you can apply the exact same handling to the first one as well.

     

    Let me know if there’s anything else I can help with.


    Regards,

    Damyan Petev

    Associate Software Developer

    Infragistics, Inc.

Children
No Data