mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2024-11-19 18:00:17 +01:00
FIX: Don't allow more than one leading zero.
This commit is contained in:
parent
974b00e4f2
commit
50efce8b84
@ -1988,12 +1988,22 @@ export class BlueBitcoinAmount extends Component {
|
|||||||
{...this.props}
|
{...this.props}
|
||||||
keyboardType="numeric"
|
keyboardType="numeric"
|
||||||
onChangeText={text => {
|
onChangeText={text => {
|
||||||
|
text = text.trim();
|
||||||
text = text.replace(',', '.');
|
text = text.replace(',', '.');
|
||||||
|
const split = text.split('.');
|
||||||
|
if (split.length >= 2) {
|
||||||
|
text = `${parseInt(split[0], 10)}.${split[1]}`;
|
||||||
|
}
|
||||||
text = this.props.unit === BitcoinUnit.BTC ? text.replace(/[^0-9.]/g, '') : text.replace(/[^0-9]/g, '');
|
text = this.props.unit === BitcoinUnit.BTC ? text.replace(/[^0-9.]/g, '') : text.replace(/[^0-9]/g, '');
|
||||||
text = text.replace(/(\..*)\./g, '$1');
|
text = text.replace(/(\..*)\./g, '$1');
|
||||||
|
|
||||||
if (text.startsWith('.')) {
|
if (text.startsWith('.')) {
|
||||||
text = '0.';
|
text = '0.';
|
||||||
}
|
}
|
||||||
|
text = text.replace(/(0{1,}.)\./g, '$1');
|
||||||
|
if (this.props.unit !== BitcoinUnit.BTC) {
|
||||||
|
text = text.replace(/[^0-9.]/g, '');
|
||||||
|
}
|
||||||
this.props.onChangeText(text);
|
this.props.onChangeText(text);
|
||||||
}}
|
}}
|
||||||
onBlur={() => {
|
onBlur={() => {
|
||||||
|
Loading…
Reference in New Issue
Block a user