From 1abe35aa58722ddf323b184641854ac1ec3b57b6 Mon Sep 17 00:00:00 2001 From: sairaj mote Date: Thu, 21 Dec 2023 00:55:00 +0530 Subject: [PATCH] Fixed address validation issue when adding contact --- index.html | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/index.html b/index.html index 91d7fdf..b09547d 100644 --- a/index.html +++ b/index.html @@ -1657,14 +1657,18 @@ else return contactAddress } + function isValidEthereumAddress(address) { + return /^0x[a-fA-F0-9]{40}$/.test(address); + } window.addEventListener('hashchange', e => routeTo(window.location.hash)) window.addEventListener("load", () => { document.body.classList.remove('hidden') document.querySelectorAll('sm-input[data-address]').forEach(input => input.customValidation = (value) => { - if (!value) return { isValid: false, errorText: 'Please enter a FLO address' } + if (!value) return { isValid: false, errorText: 'Please enter an address' } + return { - isValid: floCrypto.validateAddr(value), - errorText: `Invalid FLO address.
It usually starts with "F"` + isValid: isValidEthereumAddress(value) || floCrypto.validateAddr(value), + errorText: `Invalid address.` } }) document.addEventListener('keyup', (e) => {