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 :


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 =;
        $scope.pocs =;
        $scope.reservation.employee =;
        $scope.updateReservation = function () {
            if ($scope.editReservationForm.$valid) {
                reservationServices.updateReservation($scope.reservation).then(function (result) {
                    $ =;
                    if (! {
                        $state.transitionTo('employeeTalentPool', {
                            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 () {

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.
Updated 29-Sep-16 23:15pm
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