diff --git a/public/js/va-register.js b/public/js/va-register.js index 7dfbb13..fea6594 100644 --- a/public/js/va-register.js +++ b/public/js/va-register.js @@ -822,18 +822,37 @@ const payoneerError = document.getElementById('payoneer-error'); const value = input.value.trim(); - // Payoneer typically uses email format or alphanumeric IDs - // Adjust validation rules based on Payoneer's actual format requirements - if (value.length > 0 && (value.length < 5 || value.length > 20)) { - payoneerError.textContent = 'Payoneer account must be 5-20 characters'; - payoneerError.style.display = 'block'; - input.style.border = '1px solid #ef4445'; - return false; - } else { - payoneerError.style.display = 'none'; - input.style.border = ''; - return true; + // Remove any validation styling first + input.style.border = ''; + payoneerError.style.display = 'none'; + + if (value.length > 0) { + // Check length + if (value.length < 5 || value.length > 20) { + payoneerError.textContent = 'Payoneer account must be 5-20 digits'; + payoneerError.style.display = 'block'; + input.style.border = '1px solid #ef4444'; + return false; + } + + // Check if contains only digits + if (!/^\d+$/.test(value)) { + payoneerError.textContent = 'Payoneer account must contain digits only'; + payoneerError.style.display = 'block'; + input.style.border = '1px solid #ef4444'; + return false; + } + + // Check if all zeros + if (/^0+$/.test(value)) { + payoneerError.textContent = 'Payoneer account cannot be all zeros'; + payoneerError.style.display = 'block'; + input.style.border = '1px solid #ef4444'; + return false; + } } + + return true; } // Function to validate Veem account number @@ -841,17 +860,37 @@ const veemError = document.getElementById('veem-error'); const value = input.value.trim(); - // Veem account numbers are typically longer alphanumeric strings - if (value.length > 0 && (value.length < 8 || value.length > 25)) { - veemError.textContent = 'Veem account must be 8-25 characters'; - veemError.style.display = 'block'; - input.style.border = '1px solid #ef4445'; - return false; - } else { - veemError.style.display = 'none'; - input.style.border = ''; - return true; + // Remove any validation styling first + input.style.border = ''; + veemError.style.display = 'none'; + + if (value.length > 0) { + // Check length + if (value.length < 8 || value.length > 25) { + veemError.textContent = 'Veem account must be 8-25 digits'; + veemError.style.display = 'block'; + input.style.border = '1px solid #ef4444'; + return false; + } + + // Check if contains only digits + if (!/^\d+$/.test(value)) { + veemError.textContent = 'Veem account must contain digits only'; + veemError.style.display = 'block'; + input.style.border = '1px solid #ef4444'; + return false; + } + + // Check if all zeros + if (/^0+$/.test(value)) { + veemError.textContent = 'Veem account cannot be all zeros'; + veemError.style.display = 'block'; + input.style.border = '1px solid #ef4444'; + return false; + } } + + return true; } function showError(message, fieldId = null, step = null) { @@ -923,4 +962,17 @@ } else { option.style.display = ""; } - } \ No newline at end of file + } + +function validateSkypeId(input) { + const value = input.value.trim(); + + if (value && !/^[a-zA-Z][a-zA-Z0-9\.,\-_]+$/.test(value)) { + input.style.border = '1px solid #ef4444'; + showError('Skype ID must start with a letter and can only contain letters, numbers, dots, hyphens, and underscores', 'skype', 3); + return false; + } else { + input.style.border = ''; + return true; + } +} \ No newline at end of file diff --git a/src/server.js b/src/server.js index 005d606..5e99b37 100644 --- a/src/server.js +++ b/src/server.js @@ -77,7 +77,7 @@ app.get('/varegister/:sf_token?', (req, res) => { const { sf_token } = req.params; try { - // const decoded = jwt.verify(sf_token, process.env.JWT_SECRET_SF_TOKEN); + const decoded = jwt.verify(sf_token, process.env.JWT_SECRET_SF_TOKEN); if (decoded) { const email = decoded.email; diff --git a/views/va_register.ejs b/views/va_register.ejs index db69af9..3bf2223 100644 --- a/views/va_register.ejs +++ b/views/va_register.ejs @@ -307,7 +307,7 @@
- +
@@ -334,7 +334,7 @@
- +