From 9e55135d382b0b38da9d677c828c36342f73a59e Mon Sep 17 00:00:00 2001 From: Alex Cheung Date: Wed, 19 Jun 2024 16:20:46 +0800 Subject: [PATCH] update check captcha --- .../auth-forms/BusCustomFormWizard.js | 14 +++++++++----- .../authentication/auth-forms/CustomFormWizard.js | 3 ++- .../auth-forms/IAmSmartFormWizard.js | 8 ++++++-- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/pages/authentication/auth-forms/BusCustomFormWizard.js b/src/pages/authentication/auth-forms/BusCustomFormWizard.js index 25afb1b..9fe444c 100644 --- a/src/pages/authentication/auth-forms/BusCustomFormWizard.js +++ b/src/pages/authentication/auth-forms/BusCustomFormWizard.js @@ -197,7 +197,9 @@ const BusCustomFormWizard = (props) => { const checkDataField = (data) => { // console.log(data.brExpiryDate) - if (data.username !== "" && + if ( + handleCaptcha(data.captchaField) && + data.username !== "" && data.password !== "" && data.confirmPassword !== "" && data.password === data.confirmPassword && @@ -212,14 +214,12 @@ const BusCustomFormWizard = (props) => { data.phoneCountryCode !== "" && termsAndConAccept === true && fileList.length !== 0 && - data.captchaField && data.brNo !== "" && data.brExpiryDate !== "" && handlePassword(data.password) && handleEmail(data.email) && handlePhone(data.phone) && handleUserName(data.username) && - handleCaptcha(data.captchaField) && handleBrNo(data.brNo) && !checkUsername ) { @@ -444,7 +444,11 @@ const BusCustomFormWizard = (props) => { } function handleCaptcha(captchaField) { - return captchaField; + if (captchaField.length == 5 ){ + return true + } else { + return false + } } function handlePassword(password) { @@ -554,7 +558,7 @@ const BusCustomFormWizard = (props) => { } } }), - captchaField: yup.string().max(5, getMaxErrStr(5)).required(displayErrorMsg(intl.formatMessage({id: 'requireVerify'}))),//.oneOf([captcha], displayErrorMsg('請輸入有效驗證')) + captchaField: yup.string().max(5, getMaxErrStr(5)).required(displayErrorMsg(intl.formatMessage({ id: 'requireVerify' }))).min(5, displayErrorMsg(intl.formatMessage({ id: 'requireVerify' }))),//.oneOf([captcha], displayErrorMsg('請輸入有效驗證')), }, ['enCompanyName', 'chCompanyName']), }); diff --git a/src/pages/authentication/auth-forms/CustomFormWizard.js b/src/pages/authentication/auth-forms/CustomFormWizard.js index 6ad39f6..a0a902f 100644 --- a/src/pages/authentication/auth-forms/CustomFormWizard.js +++ b/src/pages/authentication/auth-forms/CustomFormWizard.js @@ -189,7 +189,8 @@ const CustomFormWizard = (props) => { const checkDataField = (data) => { // console.log(data) - if (handleCaptcha(data.captchaField) && + if ( + handleCaptcha(data.captchaField) && data.username !== "" && data.password !== "" && data.confirmPassword !== "" && diff --git a/src/pages/authentication/auth-forms/IAmSmartFormWizard.js b/src/pages/authentication/auth-forms/IAmSmartFormWizard.js index 63abed2..93dfd2b 100644 --- a/src/pages/authentication/auth-forms/IAmSmartFormWizard.js +++ b/src/pages/authentication/auth-forms/IAmSmartFormWizard.js @@ -366,7 +366,11 @@ const CustomFormWizard = (props) => { } function handleCaptcha(captchaField) { - return captchaField; + if (captchaField.length == 5 ){ + return true + } else { + return false + } } function handleEmail(email) { @@ -404,7 +408,7 @@ const CustomFormWizard = (props) => { emailConfirm: yup.string().email(displayErrorMsg(intl.formatMessage({ id: 'validEmailFormat' }))).max(128, getMaxErrStr(128)).required(displayErrorMsg(intl.formatMessage({ id: 'requireEmail' }))).oneOf([yup.ref('email'), null], displayErrorMsg(intl.formatMessage({ id: 'validSameEmail' }))), phoneCountryCode: yup.string().min(2, displayErrorMsg(intl.formatMessage({ id: 'requireAtLeast2Number' }))).required(displayErrorMsg(intl.formatMessage({ id: 'requireDialingCode' }))), phone: yup.string().min(8, displayErrorMsg(intl.formatMessage({ id: 'requireAtLeast8Number' }))).required(displayErrorMsg(intl.formatMessage({ id: 'requireContactNumber' }))), - captchaField: yup.string().max(5, getMaxErrStr(5)).required(displayErrorMsg(intl.formatMessage({ id: 'requireVerify' }))),//.oneOf([captcha], displayErrorMsg('請輸入有效驗證')), + captchaField: yup.string().max(5, getMaxErrStr(5)).required(displayErrorMsg(intl.formatMessage({ id: 'requireVerify' }))).min(5, displayErrorMsg(intl.formatMessage({ id: 'requireVerify' }))),//.oneOf([captcha], displayErrorMsg('請輸入有效驗證')), }), });