diff options
| author | luigi1111 <luigi1111w@gmail.com> | 2019-12-05 08:53:47 -0600 |
|---|---|---|
| committer | luigi1111 <luigi1111w@gmail.com> | 2019-12-05 08:53:47 -0600 |
| commit | 648b775a259fe2524e662560c0b61c4beede635c (patch) | |
| tree | 5a9191992fe7e9663308caf0fda45e7a772fe344 | |
| parent | b24ccc2fe385d099309c77f3b495554db9f53535 (diff) | |
| parent | e81a589a8daea22ba1e847f1c785d96d44347332 (diff) | |
| download | monzero-gui-648b775a259fe2524e662560c0b61c4beede635c.tar.gz monzero-gui-648b775a259fe2524e662560c0b61c4beede635c.tar.xz monzero-gui-648b775a259fe2524e662560c0b61c4beede635c.zip | |
Merge pull request #2559
e81a589 Transfer: improve amount sanitization (xiphon)
| -rw-r--r-- | pages/Transfer.qml | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/pages/Transfer.qml b/pages/Transfer.qml index c3ec8ac3..3d0fbeb4 100644 --- a/pages/Transfer.qml +++ b/pages/Transfer.qml @@ -182,9 +182,17 @@ Rectangle { inlineButtonText: qsTr("All") + translationManager.emptyString inlineButton.onClicked: amountLine.text = "(all)" onTextChanged: { - if(amountLine.text.indexOf('.') === 0){ - amountLine.text = '0' + amountLine.text; - } + const match = amountLine.text.match(/^0+(\d.*)/); + if (match) { + const cursorPosition = amountLine.cursorPosition; + amountLine.text = match[1]; + amountLine.cursorPosition = Math.max(cursorPosition, 1) - 1; + } else if(amountLine.text.indexOf('.') === 0){ + amountLine.text = '0' + amountLine.text; + if (amountLine.text.length > 2) { + amountLine.cursorPosition = 1; + } + } } validator: RegExpValidator { |
