diff options
author | Kevin Serrano <kevin.serrano@consensys.net> | 2017-12-28 10:22:10 +0800 |
---|---|---|
committer | Kevin Serrano <kevin.serrano@consensys.net> | 2017-12-28 10:22:10 +0800 |
commit | e682fb05fcdeca5f50a2176934d25935e13538f6 (patch) | |
tree | 825eee0cb26aca71d796f7564554cfd056106aca /ui/app | |
parent | 92eb16fc112eeac749c0ddfff163773ce3a35ef2 (diff) | |
download | tangerine-wallet-browser-e682fb05fcdeca5f50a2176934d25935e13538f6.tar tangerine-wallet-browser-e682fb05fcdeca5f50a2176934d25935e13538f6.tar.gz tangerine-wallet-browser-e682fb05fcdeca5f50a2176934d25935e13538f6.tar.bz2 tangerine-wallet-browser-e682fb05fcdeca5f50a2176934d25935e13538f6.tar.lz tangerine-wallet-browser-e682fb05fcdeca5f50a2176934d25935e13538f6.tar.xz tangerine-wallet-browser-e682fb05fcdeca5f50a2176934d25935e13538f6.tar.zst tangerine-wallet-browser-e682fb05fcdeca5f50a2176934d25935e13538f6.zip |
Add frontend validation to ensure that ether inputs are valid.
Diffstat (limited to 'ui/app')
-rw-r--r-- | ui/app/send.js | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/ui/app/send.js b/ui/app/send.js index 7b31eef7e..09c9e03d4 100644 --- a/ui/app/send.js +++ b/ui/app/send.js @@ -247,16 +247,26 @@ SendTransactionScreen.prototype.onSubmit = function () { const recipient = state.recipient || document.querySelector('input[name="address"]').value.replace(/^[.\s]+|[.\s]+$/g, '') const nickname = state.nickname || ' ' const input = document.querySelector('input[name="amount"]').value + const parts = input.split('') - if (isNaN(input)) { + let message + + if (isNaN(input) || input === '') { message = 'Invalid ether value.' return this.props.dispatch(actions.displayWarning(message)) } + if (parts[1]) { + var decimal = parts[1] + if (decimal.length > 18) { + message = 'Ether amount is too precise.' + return this.props.dispatch(actions.displayWarning(message)) + } + } + const value = util.normalizeEthStringToWei(input) const txData = document.querySelector('input[name="txData"]').value const balance = this.props.balance - let message if (value.gt(balance)) { message = 'Insufficient funds.' |