I have added a datepicker to a popup in my application which works fine, But when I try to submit the form I am not able to save the entries .My form validator returns false even though there is a valid date in the input text, But if I change the date then form validator returns true.. This is my code
<p class="input-group">
<input type="text" ng-click="open($event)" class="form-control registration-input"
datepicker-popup="{{format}}" show-button-bar="false"
ng-model="CompanyData.dateOfRegistration" name="dateOfRegistration"
is-open="opened" datepicker-options="dateOptions" /> <span
class="input-group-btn">
<button type="button" class="btn btn-default"
ng-click="open($event)">
<i class="glyphicon glyphicon-calendar"></i>
</button>
</span>
</p>
Below is the js code
// Disable weekend selection
$scope.disabled = function(date, mode) {
return ( mode === 'day' && ( date.getDay() === 0 || date.getDay() === 6 ) );
};
$scope.dates = [{date:'01-05-2001'}, {date:'05-05-2014'}, {date:'10-11-2008'}]
$scope.open = function($event) {
$event.preventDefault();
$event.stopPropagation();
$scope.opened = true;
};
$scope.dateOptions = {
formatYear: 'yy',
startingDay: 1,
showWeeks:'false'
};
$scope.format = 'dd-MMMM-yyyy'
Can anyone tell me what shuld I do in order to make this work..
My form validator returns false even though there is a valid date in the input text ?
It's because of ngModel CompanyData.dateOfRegistration
is not set initially and it is undefined
which is false.
Even there valid date in datepicker but because ngModel
is not initialised it is return false;
Set the CompanyData.dateOfRegistration
to valid date.