This repository has been archived by the owner on Jul 1, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tested with AngularJS 1.4.x branch & fixed #55
- Made sure Angular-Validation works with AngularJS 1.4.x branch, updated my Rev to 1.4.x branch as well - Also fixed issue #55, ui bootsrap datepicker and angular-validation
- Loading branch information
1 parent
f0504cd
commit 113eb95
Showing
13 changed files
with
171 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
'use strict'; | ||
|
||
var myApp = angular.module('myApp', ['ghiscoding.validation', 'pascalprecht.translate', 'ui.bootstrap']); | ||
|
||
myApp.config(['$compileProvider', function ($compileProvider) { | ||
$compileProvider.debugInfoEnabled(false); | ||
}]) | ||
.config(['$translateProvider', function ($translateProvider) { | ||
$translateProvider.useStaticFilesLoader({ | ||
prefix: '../../locales/validation/', | ||
suffix: '.json' | ||
}); | ||
// load English ('en') table on startup | ||
$translateProvider.preferredLanguage('en').fallbackLanguage('en'); | ||
}]); | ||
|
||
myApp.controller('Ctrl', | ||
['$scope', '$translate', 'validationService', '$timeout', | ||
function ($scope, $translate, validationService, $timeout) { | ||
var vm = this; | ||
vm.model = {}; | ||
vm.validationRequired = false; | ||
vm.isChangeDatePickerOpen = false; | ||
vm.datePickerFormat = 'dd/MM/yyyy'; | ||
vm.dateOptions = { formatYear: 'yy' }; | ||
|
||
vm.minDate = new Date(); // 10 years ago | ||
vm.minDate.setHours(0,0,0,0); | ||
vm.minDate.setMonth(vm.minDate.getMonth() - 12 * 10); | ||
vm.maxDate = new Date(); // now | ||
vm.maxDate.setHours(0,0,0,0); | ||
|
||
this.openDatePicker = function($event) { | ||
console.log("openDatePicker()", vm.isChangeDatePickerOpen); | ||
$event.preventDefault(); | ||
$event.stopPropagation(); | ||
vm.isChangeDatePickerOpen = true; | ||
}; | ||
|
||
var validation = new validationService({ | ||
controllerAs: vm, | ||
preValidateFormElements: false | ||
}); | ||
|
||
vm.checkboxChange = function() { | ||
validation.checkFormValidity(vm.test); // force validation | ||
} | ||
}]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<!DOCTYPE html> | ||
<html ng-app="myApp" ng-strict-di ng-cloak=""> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title>Angular-Validation Example with Interpolation</title> | ||
<link rel="stylesheet" href="https://netdna.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css"> | ||
<link rel="stylesheet" href="../../style.css"> | ||
</head> | ||
|
||
<body ng-controller="Ctrl as vm"> | ||
<div class="container"> | ||
<h2>Example of Angular-Validation Date validation error after select from ui datepicker.</h2> | ||
<hr/> | ||
<label class="control-label">Min Date {{vm.minDate}}</label> | ||
<label class="control-label">Max Date {{vm.maxDate}}</label> | ||
<hr/> | ||
<form name="vm.test"> | ||
<label class="control-label">Date</label> | ||
<div class="input-group"> | ||
<input | ||
type="text" | ||
id="dateOfChange" | ||
name="dateOfChange" | ||
class="form-control" | ||
validation="required|date_euro_long_between:{{vm.minDate | date:'dd/MM/yyyy'}},{{vm.maxDate | date:'dd/MM/yyyy'}}" | ||
validation-error-to="dateOfChangeValidation" | ||
ng-model="vm.model.dateOfChange" | ||
datepicker-popup="{{vm.datePickerFormat}}" | ||
datepicker-options="vm.dateOptions" | ||
datepicker-mode="'day'" | ||
is-open="vm.isChangeDatePickerOpen" | ||
min-date="vm.minDate" | ||
max-date="vm.maxDate" | ||
/> | ||
<span class="input-group-btn"> | ||
<button type="button" class="btn btn-default" | ||
data-ng-click="vm.openDatePicker($event)"> | ||
<i class="glyphicon glyphicon-calendar"></i> | ||
</button> | ||
</span> | ||
</div> | ||
<div id="dateOfChangeValidation" class="validation text-danger"></div> | ||
</form> | ||
|
||
|
||
<br/> | ||
<br/> | ||
<div class="alert alert-danger alert-dismissable" ng-show="vm.test.$validationSummary.length > 0"> | ||
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button> | ||
<h4><strong>ERRORS!</strong></h4> | ||
<ul> | ||
<li ng-repeat="item in vm.test.$validationSummary">{{ item.friendlyName != '' ? item.friendlyName : item.field }}: {{item.message}}</li> | ||
</ul> | ||
</div> | ||
|
||
<ng-view></ng-view> | ||
</div> | ||
|
||
<!-- external librairies CDN --> | ||
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.js"></script> | ||
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular-route.js"></script> | ||
|
||
<!-- angular-translate --> | ||
<!-- Visit Angular-Translate https://github.com/PascalPrecht/angular-translate --> | ||
<script src="../../vendors/angular-translate/angular-translate.min.js"></script> | ||
<script src="../../vendors/angular-translate/angular-translate-loader-static-files.min.js"></script> | ||
|
||
<!-- Angular-UI --> | ||
<script src="https://angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.13.2.js"></script> | ||
|
||
<!-- Angular-Validation --> | ||
<script type="text/javascript" src="../../dist/angular-validation.min.js"></script> | ||
<!-- | ||
<script type="text/javascript" src="../../src/validation-directive.js"></script> | ||
<script type="text/javascript" src="../../src/validation-service.js"></script> | ||
<script type="text/javascript" src="../../src/validation-common.js"></script> | ||
<script type="text/javascript" src="../../src/validation-rules.js"></script> | ||
--> | ||
|
||
<!-- my application --> | ||
<script type="text/javascript" src="app.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters