diff --git a/oidc-ui/src/components/InputWithImage.js b/oidc-ui/src/components/InputWithImage.js index 9e56f9cf6..d088b19ba 100644 --- a/oidc-ui/src/components/InputWithImage.js +++ b/oidc-ui/src/components/InputWithImage.js @@ -262,7 +262,7 @@ export default function InputWithImage({ onBlur={onBlurChange} onKeyDown={handleKeyDown} onKeyUp={handleKeyUp} - value={value} + // value={value} type={type} id={id} name={name} diff --git a/oidc-ui/src/components/InputWithPrefix.js b/oidc-ui/src/components/InputWithPrefix.js index cee1a0db2..cc24eca6f 100644 --- a/oidc-ui/src/components/InputWithPrefix.js +++ b/oidc-ui/src/components/InputWithPrefix.js @@ -76,23 +76,20 @@ const InputWithPrefix = (props) => { const regex = idProperties.regex ? new RegExp(idProperties.regex) : null; const trimmedValue = e.target.value.trim(); - let newValue = regex + let newValue = regex && regex.test(trimmedValue) ? trimmedValue - .split("") - .filter((char) => regex.test(char)) - .join("") : trimmedValue; - + setIndividualId(newValue); props.individualId(newValue); // Update state with the visible valid value const isValidInput = (!maxLength && !regex) || // Case 1: No maxLength, no regex - (maxLength && !regex && newValue.length === parseInt(maxLength)) || // Case 2: maxLength only + (maxLength && !regex && newValue.length <= parseInt(maxLength)) || // Case 2: maxLength only (!maxLength && regex && regex.test(newValue)) || // Case 3: regex only (maxLength && regex && - newValue.length === parseInt(maxLength) && + newValue.length <= parseInt(maxLength) && regex.test(newValue)); // Case 4: Both maxLength and regex props.isBtnDisabled(!isValidInput); @@ -106,7 +103,7 @@ const InputWithPrefix = (props) => { const maxLength = idProperties.maxLength; const regex = idProperties.regex ? new RegExp(idProperties.regex) : null; setIsValid( - (!maxLength || e.target.value.trim().length === parseInt(maxLength)) && + (!maxLength || e.target.value.trim().length <= parseInt(maxLength)) && (!regex || regex.test(e.target.value.trim())) ); }; diff --git a/oidc-ui/src/components/L1Biometrics.js b/oidc-ui/src/components/L1Biometrics.js index 325567c50..9597aeafb 100644 --- a/oidc-ui/src/components/L1Biometrics.js +++ b/oidc-ui/src/components/L1Biometrics.js @@ -129,11 +129,8 @@ export default function L1Biometrics({ const regex = idProperties.regex ? new RegExp(idProperties.regex) : null; const trimmedValue = e.target.value.trim(); - let newValue = regex + let newValue = regex && regex.test(trimmedValue) ? trimmedValue - .split("") - .filter((char) => regex.test(char)) - .join("") : trimmedValue; setIndividualId(newValue); // Update state with the visible valid value @@ -142,11 +139,11 @@ export default function L1Biometrics({ !( ( (!maxLength && !regex) || // Case 1: No maxLength, no regex - (maxLength && !regex && newValue.length === parseInt(maxLength)) || // Case 2: maxLength only + (maxLength && !regex && newValue.length <= parseInt(maxLength)) || // Case 2: maxLength only (!maxLength && regex && regex.test(newValue)) || // Case 3: regex only (maxLength && regex && - newValue.length === parseInt(maxLength) && + newValue.length <= parseInt(maxLength) && regex.test(newValue)) ) // Case 4: Both maxLength and regex ) @@ -161,7 +158,7 @@ export default function L1Biometrics({ const maxLength = idProperties.maxLength; const regex = idProperties.regex ? new RegExp(idProperties.regex) : null; setIsValid( - (!maxLength || e.target.value.trim().length === parseInt(maxLength)) && + (!maxLength || e.target.value.trim().length <= parseInt(maxLength)) && (!regex || regex.test(e.target.value.trim())) ); }; @@ -386,7 +383,7 @@ export default function L1Biometrics({ } propChange({ disable: - !individualId?.trim() || + !individualId || isBtnDisabled || (showCaptcha && captchaToken === null), onCapture: (e) => authenticateBiometricResponse(e), diff --git a/oidc-ui/src/components/OtpGet.js b/oidc-ui/src/components/OtpGet.js index d2d9125ad..d2913edd1 100644 --- a/oidc-ui/src/components/OtpGet.js +++ b/oidc-ui/src/components/OtpGet.js @@ -128,11 +128,8 @@ export default function OtpGet({ const regex = idProperties.regex ? new RegExp(idProperties.regex) : null; const trimmedValue = e.target.value.trim(); - let newValue = regex + let newValue = regex && regex.test(trimmedValue) ? trimmedValue - .split("") - .filter((char) => regex.test(char)) - .join("") : trimmedValue; setIndividualId(newValue); // Update state with the visible valid value @@ -141,11 +138,11 @@ export default function OtpGet({ !( ( (!maxLength && !regex) || // Case 1: No maxLength, no regex - (maxLength && !regex && newValue.length === parseInt(maxLength)) || // Case 2: maxLength only + (maxLength && !regex && newValue.length <= parseInt(maxLength)) || // Case 2: maxLength only (!maxLength && regex && regex.test(newValue)) || // Case 3: regex only (maxLength && regex && - newValue.length === parseInt(maxLength) && + newValue.length <= parseInt(maxLength) && regex.test(newValue)) ) // Case 4: Both maxLength and regex ) @@ -160,7 +157,7 @@ export default function OtpGet({ const maxLength = idProperties.maxLength; const regex = idProperties.regex ? new RegExp(idProperties.regex) : null; setIsValid( - (!maxLength || e.target.value.trim().length === parseInt(maxLength)) && + (!maxLength || e.target.value.trim().length <= parseInt(maxLength)) && (!regex || regex.test(e.target.value.trim())) ); }; @@ -342,7 +339,7 @@ export default function OtpGet({ handleClick={sendOTP} id="get_otp" disabled={ - !individualId?.trim() || + !individualId || isBtnDisabled || (showCaptcha && captchaToken === null) } diff --git a/oidc-ui/src/components/Password.js b/oidc-ui/src/components/Password.js index 37bde58e8..a255aa654 100644 --- a/oidc-ui/src/components/Password.js +++ b/oidc-ui/src/components/Password.js @@ -120,11 +120,8 @@ export default function Password({ const regex = idProperties.regex ? new RegExp(idProperties.regex) : null; const trimmedValue = e.target.value.trim(); - let newValue = regex + let newValue = regex && regex.test(trimmedValue) ? trimmedValue - .split("") - .filter((char) => regex.test(char)) - .join("") : trimmedValue; setIndividualId(newValue); // Update state with the visible valid value @@ -138,11 +135,11 @@ export default function Password({ !( ( (!maxLength && !regex) || // Case 1: No maxLength, no regex - (maxLength && !regex && newValue.length === parseInt(maxLength)) || // Case 2: maxLength only + (maxLength && !regex && newValue.length <= parseInt(maxLength)) || // Case 2: maxLength only (!maxLength && regex && regex.test(newValue)) || // Case 3: regex only (maxLength && regex && - newValue.length === parseInt(maxLength) && + newValue.length <= parseInt(maxLength) && regex.test(newValue)) ) // Case 4: Both maxLength and regex ) @@ -157,7 +154,7 @@ export default function Password({ const maxLength = idProperties.maxLength; const regex = idProperties.regex ? new RegExp(idProperties.regex) : null; setIsValid( - (!maxLength || e.target.value.trim().length === parseInt(maxLength)) && + (!maxLength || e.target.value.trim().length <= parseInt(maxLength)) && (!regex || regex.test(e.target.value.trim())) ); }; @@ -497,7 +494,7 @@ export default function Password({ id="verify_password" className="mt-2" disabled={ - !individualId?.trim() || + !individualId || !password?.trim() || isBtnDisabled || (inputErrorBanner && inputErrorBanner.length > 0) || diff --git a/oidc-ui/src/components/Pin.js b/oidc-ui/src/components/Pin.js index cc964c063..9b43bd97b 100644 --- a/oidc-ui/src/components/Pin.js +++ b/oidc-ui/src/components/Pin.js @@ -116,11 +116,8 @@ export default function Pin({ const regex = idProperties.regex ? new RegExp(idProperties.regex) : null; const trimmedValue = e.target.value.trim(); - let newValue = regex + let newValue = regex && regex.test(trimmedValue) ? trimmedValue - .split("") - .filter((char) => regex.test(char)) - .join("") : trimmedValue; setIndividualId(newValue); // Update state with the visible valid value @@ -134,11 +131,11 @@ export default function Pin({ !( ( (!maxLength && !regex) || // Case 1: No maxLength, no regex - (maxLength && !regex && newValue.length === parseInt(maxLength)) || // Case 2: maxLength only + (maxLength && !regex && newValue.length <= parseInt(maxLength)) || // Case 2: maxLength only (!maxLength && regex && regex.test(newValue)) || // Case 3: regex only (maxLength && regex && - newValue.length === parseInt(maxLength) && + newValue.length <= parseInt(maxLength) && regex.test(newValue)) ) // Case 4: Both maxLength and regex ) @@ -153,7 +150,7 @@ export default function Pin({ const maxLength = idProperties.maxLength; const regex = idProperties.regex ? new RegExp(idProperties.regex) : null; setIsValid( - (!maxLength || e.target.value.trim().length === parseInt(maxLength)) && + (!maxLength || e.target.value.trim().length <= parseInt(maxLength)) && (!regex || regex.test(e.target.value.trim())) ); }; @@ -463,7 +460,7 @@ export default function Pin({ text={t1("login")} id="verify_pin" disabled={ - !individualId?.trim() || + !individualId || !pin?.trim() || isBtnDisabled || (inputError && inputError.length > 0) ||