0

I only want numeric character input in the pattern, but it also accepts when I say ms3 for example. I want only numeric characters to be accepted. How do you think I can do?

<td>
                                                    <input
                                                        type="text"
                                                        className="form-control text-uppercase"
                                                        id="date_of_delivery"
                                                        name="date_of_delivery"
                                                        defaultValue={offer.date_of_delivery}
                                                        {...register("date_of_delivery", {
                                                            required: true,
                                                            pattern: /[0-9]/,
                                                        })}
                                                    />
                                                    {errors?.date_of_delivery?.type === "required" &&
                                                        <p>Bu alan zorunludur.</p>}
                                                    {errors?.date_of_delivery?.type === "pattern" && <p>Lütfen sayısal bir değer giriniz.</p>}
                                                </td>
1

1 Answer 1

1
<td>
                                                    <input
                                                        type="text"
                                                        className="form-control text-uppercase"
                                                        id="date_of_delivery"
                                                        name="date_of_delivery"
                                                        defaultValue={offer.date_of_delivery}
                                                        {...register("date_of_delivery", {
                                                            required: true,
                                                           pattern: /^[0-9]{11}$/,
                                                        })}
                                                    />
                                                    {errors?.date_of_delivery?.type=== "required" &&<p>Bu alan zorunludur.</p>}
{errors?.date_of_delivery?.type === "pattern" && <p>Lütfen sayısal bir değer  giriniz.</p>}
                                                </td>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.