diff --git a/src/pages/authentication/auth-forms/BusCustomFormWizard.js b/src/pages/authentication/auth-forms/BusCustomFormWizard.js index 4066aeb..907ae7d 100644 --- a/src/pages/authentication/auth-forms/BusCustomFormWizard.js +++ b/src/pages/authentication/auth-forms/BusCustomFormWizard.js @@ -136,8 +136,8 @@ const BusCustomFormWizard = (props) => { data.password !==""&& data.confirmPassword !==""&& data.password == data.confirmPassword&& - (data.enCompanyName !=="" || selectedAddress5 ==="內地")&& - data.chCompanyName !==""&& + // (data.enCompanyName !=="" || selectedAddress5 ==="內地")&& + (data.chCompanyName !=="" || data.enCompanyName !== "")&& data.enName !==""&& data.chName !==""&& data.address1 !==""&& @@ -400,6 +400,7 @@ const BusCustomFormWizard = (props) => { return true; } } + const formik = useFormik({ initialValues:({ @@ -423,6 +424,7 @@ const BusCustomFormWizard = (props) => { emailConfirm:'', captchaField:'' }), + validationSchema:yup.object().shape({ username: yup.string().min(6,'用戶名稱最少6位').required('請輸入用戶名稱') .matches(/^[aA-zZ0-9\s]+$/, "用戶名稱不包含特殊字符") @@ -435,8 +437,14 @@ const BusCustomFormWizard = (props) => { .matches(/^(?=.*[!@#%&])/, '請包括最少1個特殊字符'), confirmPassword: yup.string().min(8,'請最少輸入8位密碼').required('請確認密碼').oneOf([yup.ref('password'), null], '請輸入相同密碼'), enName: yup.string().max(255).required('請輸入英文姓名'), - enCompanyName: yup.string().max(255).required('請輸入英文名稱'), - chCompanyName: yup.string().max(255).required('請輸入中文名稱'), + enCompanyName: yup.string().matches(/^[^$^*()]+$/, 'No special characters $/^/*/(/)').when('chCompanyName', { + is: (chCompanyName) => !chCompanyName || chCompanyName.length === 0, + then: yup.string().required('Please enter either English or Chinese name'), + }), + chCompanyName: yup.string().matches(/^[^$^*()]+$/, '不包含特殊字符 $/^/*/(/)').when('enCompanyName', { + is: (enCompanyName) => !enCompanyName || enCompanyName.length === 0, + then: yup.string().required('請輸入英文或中文名稱'), + }), chName: yup.string().max(255).required('請輸入中文姓名'), address1: yup.string().max(255).required('請輸入第一行地址'), address2: yup.string().max(255).required('請輸入第二行地址'), @@ -450,7 +458,7 @@ const BusCustomFormWizard = (props) => { brExpiryDate: yup.date().min(new Date().toISOString().split("T")[0], '請輸入商業登記證有效日期').max("2099-12-31", '請輸入商業登記證有效日期').required('請輸入商業登記證有效日期'), brNo: yup.string().min(8,'請輸入商業登記證號碼').required('請輸入商業登記證號碼'), captchaField: yup.string().required('請輸入驗證').oneOf([captcha], '請輸入有效驗證'), - }) + }, ['enCompanyName', 'chCompanyName']), }); @@ -650,10 +658,16 @@ const BusCustomFormWizard = (props) => { + + +
+ •請輸入機構/公司英文名稱或中文名稱
+ •Please enter the English/Chinese name of the organisation/company +
+
機構/公司英文名稱 - {selectedAddress5 === "內地" ? "" : *} { 機構/公司中文名稱 - *