L
L
lexstile2021-12-07 22:28:03
React
lexstile, 2021-12-07 22:28:03

How to trigger form submit on click on input with type button?

I'm trying to start submitting a form, but I don't understand what's going on.
How to fire a form submit event using formik ?

<Formik
            initialValues={{ phone: '' }}
            validationSchema={RegisterSchema}
            onSubmit={(values) => {
              console.log('values', values);
            }}
          >
            {({ submitForm }) => (
              <Form>
                <Field name="phone">
                  {({ field, meta }) => (
                    <FormItem
                      top="Телефон"
                      status={meta.touched && meta.error ? 'error' : 'default'}
                      bottom={meta.touched && meta.error ? meta.error : null}
                    >
                      <InputMask
                        mask="+7 999 999 99 99"
                        maskChar=" "
                        inputMode="tel"
                        value={phoneValue}
                        {...field}
                      >
                        {(inputProps) => <Input {...inputProps} type="text" placeholder="Введите телефон" />}
                      </InputMask>
                    </FormItem>
                  )}
                </Field>
                <FormItem>
                  <Button size="l" stretched onClick={submitForm}>
                    Зарегистрироваться
                  </Button>
                </FormItem>
              </Form>
            )}
          </Formik>

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question