mirror of
https://github.com/monero-project/monero-gui.git
synced 2024-11-17 16:28:14 +00:00
Merge pull request #2559
e81a589
Transfer: improve amount sanitization (xiphon)
This commit is contained in:
commit
648b775a25
1 changed files with 11 additions and 3 deletions
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue