fix phone number

This commit is contained in:
Yasiu1376
2023-12-20 14:54:13 +03:30
parent 653ee9ed0d
commit e6b90c27b4
2 changed files with 21 additions and 3 deletions

View File

@@ -99,7 +99,8 @@
"button_make_account": "ایجاد حساب",
"button_request_verification": "دریافت کد یکبارمصرف",
"sent_token_to": "ارسال کد یکبار مصرف به شماره",
"change_phone_number": "تغییر شماره"
"change_phone_number": "تغییر شماره",
"phone_number_max": "شماره تلفن می بایست 11 رقم باشد"
},
"RegisterPage": {
"link_routing_back_to": "بازگشت به",

View File

@@ -27,7 +27,12 @@ const SendUserDataComponent = ({
phone_number: PhoneNumber,
};
const validationSchema = Yup.object().shape({
phone_number: Yup.string().required(t("LoginPage.error_message_phone_number")),
phone_number: Yup.mixed()
.test("max", `${t("LoginPage.phone_number_max")}`, (value) => {
const stringValue = String(value);
return stringValue.length === 11
})
.required(t("LoginPage.error_message_phone_number")),
});
const handleSubmit = (values, props) => {
@@ -76,7 +81,19 @@ const SendUserDataComponent = ({
placeholder={t(
"LoginPage.text_field_enter_your_phone_number"
)}
type={"text"}
type={"tel"}
onChange={(event) => {
const inputValue = event.target.value;
if (isNaN(Number(inputValue))) {
return;
}
props.handleChange({
target: {
name: "phone_number",
value: inputValue,
},
});
}}
error={
!!(props.touched.phone_number && props.errors.phone_number)
}