forked from wavesplatform/WavesGUI
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(transfer): filter out non-numeric characters from decimal and in…
…teger input fields Added directives to prevent input of wrong characters to numeric input fields
- Loading branch information
1 parent
5bc2880
commit 872724b
Showing
5 changed files
with
70 additions
and
6 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
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,30 @@ | ||
(function () { | ||
'use strict'; | ||
|
||
angular | ||
.module('app.shared') | ||
.directive('decimalInputRestrictor', [function WavesDecimalInputRestrictorDirective() { | ||
return { | ||
restrict: 'A', | ||
require: 'ngModel', | ||
link: function (scope, element, attributes, ngModelController) { | ||
var pattern = /[^0-9.]+/g; | ||
|
||
function fromUser (text) { | ||
if (!text) | ||
return text; | ||
|
||
var transformedInput = text.replace(pattern, ''); | ||
if (transformedInput !== text) { | ||
ngModelController.$setViewValue(transformedInput); | ||
ngModelController.$render(); | ||
} | ||
|
||
return transformedInput; | ||
} | ||
|
||
ngModelController.$parsers.push(fromUser); | ||
} | ||
}; | ||
}]); | ||
})(); |
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,30 @@ | ||
(function () { | ||
'use strict'; | ||
|
||
angular | ||
.module('app.shared') | ||
.directive('integerInputRestrictor', [function WavesIntegerInputRestrictorDirective() { | ||
return { | ||
restrict: 'A', | ||
require: 'ngModel', | ||
link: function (scope, element, attributes, ngModelController) { | ||
var pattern = /[^0-9]+/g; | ||
|
||
function fromUser (text) { | ||
if (!text) | ||
return text; | ||
|
||
var transformedInput = text.replace(pattern, ''); | ||
if (transformedInput !== text) { | ||
ngModelController.$setViewValue(transformedInput); | ||
ngModelController.$render(); | ||
} | ||
|
||
return transformedInput; | ||
} | ||
|
||
ngModelController.$parsers.push(fromUser); | ||
} | ||
}; | ||
}]); | ||
})(); |