Click here to Skip to main content
15,891,607 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am new to Angular JS and I am trying to implement validation for date time picker in my Angular project.

I am using bootstrap date picker.

My HTML is :

<div>
    
    </div>


My Controller is :

myApp.controller('editReservationController', ['$scope', '$filter', 'reservationResolved', 'pocResolved', 'accountResolved', 'reservationServices', '$location', '$state',
    function ($scope, $filter, reservationResolved, pocResolved, accountResolved, reservationServices, $location, $state) {
        $scope.reservation = new Object();
        $scope.accounts = accountResolved.data;
        $scope.pocs = pocResolved.data;
        $scope.reservation.employee = reservationResolved.data;
        $scope.updateReservation = function () {
            if ($scope.editReservationForm.$valid) {
                reservationServices.updateReservation($scope.reservation).then(function (result) {
                    $scope.data = result.data;
                    if (!result.data.error) {
                        $state.transitionTo('employeeTalentPool', {
                            id: $state.params.id
                        });
                    }
                });
            }
        };

        $scope.checkErr = function (startDate, endDate) {
            $scope.errMessage = '';
            var curDate = new Date();

            if (new Date(startDate) > new Date(endDate)) {
                $scope.errMessage = 'End Date should be greater than start date';
                return false;
            }
            if (new Date(startDate) < curDate) {
                $scope.errMessage = 'Start date should not be before today.';
                return false;
            }
        };

        $scope.cancel = function () {
            $location.path("/reservations");
        }
    }]);



I am totally new to Angular and I'm trying to understand it by doing projects. Can anyone have a check and provide a solution?

What I have tried:

I have added it in my code. I am not sure if what i tried is correct.
Posted
Updated 29-Sep-16 22:15pm
v4
Comments
Karthik_Mahalingam 30-Sep-16 0:59am    
what is the issue

1 solution

Please, follow the example from that link: Playing with Bootstrap Datepicker - FormValidation[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900