首页 > 解决方案 > 是的,移动浏览器中的验证失败 React js

问题描述

以下代码仅在移动浏览器中给出验证错误 Q1..Q5 是下拉值。第一次选择后出现验证消息,如果从同一个下拉列表中选择另一个选项,验证错误就会消失。

initialValues : {
  Q1 : '',
  Q2 : '',
  Q3 : '',
  Q4: '',
  Q5 : ''
}

validationSchema: yup.object().shape({
  Q1 : yup.object().required('All answers are mandatory'),
  Q2 : yup.object().required('All answers are mandatory'),
  Q3 : yup.object().required('All answers are mandatory'),
  Q4 : yup.object().required('All answers are mandatory'),
  Q5 : yup.object().required('All answers are mandatory'),
});

Q1..Q5 will have the value of the form 

{ label : 'X' value : 'x' }

第一次选择后

标签: reactjsformikyup

解决方案


推荐阅读