How to Implement Form Validation in React Native: Step-by-Step Guide
-
By Devraj
-
18th November 2026
The easiest way to implement form validation in React Native is to use React Hook Form with its Controller component. You define validation rules (required, min length, pattern), connect each TextInput to the form, and show error messages from the errors object. For larger forms, add a schema library like Zod or Yup through a resolver.
In this guide from Skill Hives, you will build a working profile form with real validation rules, then learn how to scale it with schema validation.
Struggling With Complex React Native Forms?
Get hands-on guidance from Skill Hives mentors to build scalable, bug-free mobile apps using React Hook Form, Zod, and TypeScript.
Table of Content
What Is Form Validation in React Native?
Which Form Validation Library Should You Use in React Native?
Step 1: Install React Hook Form
Step 2: Set Up the Form With useForm
Step 3: Add Validation Rules With Controller
Step 4: Validate Email and Phone Number
Step 6: Choose When Validation Runs
Step 7: Use Zod for Schema Validation (TypeScript)
Step 8: Use Yup as an Alternative
Step 9: Build a Reusable Input Component
Common Form Validation Mistakes in React Native
What Is Form Validation in React Native?
Form validation is the process of checking user input before it is submitted. It catches problems such as an empty required field, an invalid email address, or a phone number with the wrong number of digits, and tells the user immediately.
Good validation improves user experience, protects your backend from bad data, and reduces failed API requests.
Which Form Validation Library Should You Use in React Native?
| Option | Best For | Notes |
|---|---|---|
| React Hook Form (built-in rules) | Most small and medium forms | Light, no dependencies, fewer re-renders |
| React Hook Form + Zod | TypeScript projects | Schema and types come from one source |
| React Hook Form + Yup | Projects already using Yup | Mature, expressive, async validation support |
Manual useState |
Very simple forms (1 or 2 fields) | Becomes messy quickly |
React Hook Form is a strong default because it isolates re-renders and keeps form state out of your component tree, which matters on mobile devices.
Step 1: Install React Hook Form
npm install react-hook-form
For schema validation later, also install a resolver and one schema library:
npm install @hookform/resolvers zod
# or
npm install @hookform/resolvers yup
Step 2: Set Up the Form With useForm
React Native has no HTML inputs, so you cannot use register directly. Use the Controller component to connect TextInput to the form.
import React from “react”;
import { View, Text, TextInput, TouchableOpacity, StyleSheet } from “react-native”;
import { useForm, Controller } from “react-hook-form”;
export default function ProfileForm() {
const {
control,
handleSubmit,
formState: { errors },
} = useForm({
defaultValues: {
bio: “”,
location: “”,
phone: “”,
},
});
const onSubmit = (data) => {
console.log(“Valid form data:”, data);
};
// JSX comes next
}
Three things to note:
- control links each field to the form.
- handleSubmit runs validation first and only calls your function if everything passes.
- defaultValues should be set for every field so your controlled inputs never start as undefined.
A common mistake is destructuring onSubmit from useForm(). It does not exist there. You define onSubmit yourself, as shown above.
Step 3: Add Validation Rules With Controller
Pass a rules object to each Controller.
(
Bio
{errors.bio && {errors.bio.message}}
)}
/>
Here is what each part does:
- rules defines what is valid.
- onChangeText={onChange} updates the form value as the user types.
- onBlur={onBlur} marks the field as touched.
- errors.bio?.message shows the message when a rule fails.
Built-in validation rules
- required: field cannot be empty
- minLength / maxLength: limits on text length
- min / max: limits on numbers
- pattern: must match a regular expression
- validate: your own custom function
Master React Native & Modern Web Development
Move beyond basic tutorials with practical, step-by-step projects designed to make you job-ready in mobile and frontend engineering.
Step 4: Validate Email and Phone Number
Email validation with a pattern:
rules={{
required: “Email is required”,
pattern: {
value: /^\S+@\S+\.\S+$/,
message: “Enter a valid email address”,
},
}}
Indian mobile number validation (10 digits, starts with 6 to 9):
rules={{
required: “Phone number is required”,
pattern: {
value: /^[6-9]\d{9}$/,
message: “Enter a valid 10-digit mobile number”,
},
}}
Change the regular expression to match your own country’s format. If you want separate messages for separate problems, use the validate rule:
rules={{
required: “Phone number is required”,
validate: {
tenDigits: (v) => v.replace(/\D/g, “”).length === 10 || “Must be exactly 10 digits”,
validStart: (v) => /^[6-9]/.test(v) || “Must start with 6, 7, 8 or 9″,
},
}}
Set keyboardType=”phone-pad” on the TextInput so users get a number keyboard.
Step 5: Submit the Form
Submit
If any rule fails, handleSubmit blocks the submission and fills the errors object so your messages appear.
Step 6: Choose When Validation Runs
Use the mode option in useForm to control timing:
useForm({ mode: “onBlur” });
| Mode | When Validation Runs |
|---|---|
onSubmit (default) |
When the user presses submit |
| onBlur | When the user leaves a field |
| onChange | On every keystroke |
| onTouched | First on blur, then on every change |
| all | On both blur and change |
For mobile forms, onBlur or onTouched usually feels best because errors do not flash while the user is still typing.
Step 7: Use Zod for Schema Validation (TypeScript)
When forms grow, keep rules in one schema instead of scattering them across components. Zod is TypeScript-first, has zero external dependencies and infers types from your schema.
import { useForm, Controller } from “react-hook-form”;
import { zodResolver } from “@hookform/resolvers/zod”;
import * as z from “zod”;
const schema = z.object({
name: z.string().min(2, “Name must be at least 2 characters”),
email: z.email(“Enter a valid email address”),
phone: z.string().regex(/^[6-9]\d{9}$/, “Enter a valid 10-digit mobile number”),
});
type FormData = z.infer;
const { control, handleSubmit, formState: { errors } } = useForm({
resolver: zodResolver(schema),
defaultValues: { name: “”, email: “”, phone: “” },
});
The Controller and TextInput code stays the same. You simply remove rules because the schema now handles validation. Zod requires TypeScript strict mode, so enable “strict”: true in your tsconfig.json.
Step 8: Use Yup as an Alternative
Yup is a schema builder for runtime value parsing and validation, with built-in async validation support.
import { yupResolver } from “@hookform/resolvers/yup”;
import * as yup from “yup”;
const schema = yup.object({
name: yup.string().required(“Name is required”).min(2),
email: yup.string().email(“Enter a valid email”).required(“Email is required”),
phone: yup.string().matches(/^[6-9]\d{9}$/, “Enter a valid mobile number”).required(),
});
const { control, handleSubmit } = useForm({ resolver: yupResolver(schema) });
Zod or Yup? Choose Zod for new TypeScript projects where you want inferred types. Choose Yup if your team already uses it or you rely on its when conditions for dependent fields.
Step 9: Build a Reusable Input Component
Repeating the same Controller block for every field gets tiring. Wrap it once:
import { Controller } from “react-hook-form”;
import { View, Text, TextInput } from “react-native”;
export function FormInput({ control, name, label, rules, error, …props }) {
return (
(
{label}
{error && {error.message}}
)}
/>
);
}
Now each field is one line:
Common Form Validation Mistakes in React Native
- Using register instead of Controller. register works for web inputs. React Native needs Controller.
- Missing defaultValues. This causes uncontrolled-to-controlled warnings and undefined values.
- Calling value.replace on undefined. Always set default values or guard with value?..
- Forgetting onBlur. Without it, onBlur and onTouched modes will not behave correctly.
- Using only client-side validation. Always validate again on your server.
- Hiding the keyboard issue. Wrap long forms in ScrollView and consider KeyboardAvoidingView.
Best Practices for React Native Form Validation
- Write clear, specific error messages such as “Enter a 10-digit mobile number” instead of “Invalid input”.
- Show errors next to the field, not only in an alert.
- Use the correct keyboardType (email-address, phone-pad, numeric).
- Validate on blur or touch for a calmer experience.
- Keep schemas in a separate file so they can be reused and tested.
- Disable the submit button while submitting to prevent duplicate requests.
Have Questions About Your React Native Project?
Chat directly with the Skill Hives team to get personalized roadmap advice, code review tips, and course recommendations.
Frequently Asked Questions
What is the best library for form validation in React Native?
React Hook Form is the most popular choice because it is lightweight, has no dependencies and minimizes re-renders. Pair it with Zod or Yup when you need schema-based validation.
Can I use React Hook Form in React Native?
Yes. Use the Controller component to wrap TextInput and other React Native components.
How do I validate a phone number in React Native?
Use a pattern rule with a regular expression such as /^[6-9]\d{9}$/ for Indian mobile numbers, or a custom validate function for separate error messages.
How do I validate an email in React Native?
Use a pattern rule in React Hook Form, z.email() in Zod, or yup.string().email() in Yup. Remember that the only way to truly confirm an email address is to send a verification email.
Should I use Zod or Yup with React Hook Form?
Both work through @hookform/resolvers. Zod fits TypeScript-first projects, while Yup is a good fit if it is already in your codebase.
Do I still need server-side validation?
Yes. Client-side validation improves user experience, but it can be bypassed, so your API must validate input too.
Conclusion
Form validation in React Native becomes simple when you follow a clear pattern: set up useForm, wrap each TextInput in a Controller, define rules, display errors, and submit with handleSubmit. Move to Zod or Yup when your forms grow.
At Skill Hives, we publish practical, beginner-friendly tutorials on React Native, React and modern web development. Explore more guides on Skill Hives to keep building real-world skills step by step.
Recent Articles
Top 50 MySQL Interview Questions and Answers for 2027
How to Implement Form Validation in React Native: Step-by-Step Guide
Data Analyst Course in Chandigarh: Fee, Syllabus & Career Scope
Top 40+ Angular Interview Questions and Answers for 2027