Click here to Skip to main content
14,430,522 members
Rate this:
Please Sign up or sign in to vote.
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 23:15pm
v4
Comments
Karthik_Mahalingam 30-Sep-16 0:59am
   
what is the issue

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

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

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100