Skip to main content

Posts

Showing posts from November, 2022

React Form Validation

Validation means to check that the data that is entered into the form is correct or not, react-js use bootstrap classes to implement validation practically. Step by Step React JS Validation Process Example1: import { useState } from "react" ; const isEmailValid = ( email ) => {     const emailPattern = / ^ [ a-zA-Z0-9._- ] + @ [ a-zA-Z0-9.- ] +\. [ a-zA-Z ] {2,10} $ / ;     return emailPattern . test ( email );   }; function Formvalidation () {     const [ inputValue , setInputValue ] = useState ( undefined );     const [ error , setError ] = useState ( undefined );     const [ email , setEmail ] = useState ( undefined );     const handleInputChange = ( e ) => {         const value = e . target . value ;       //  setInputValue(value);             // Validate if the input is not empty         if ( ! val...