Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

react check if string is mail

let handleOnChange = ( email ) => {

    // don't remember from where i copied this code, but this works.
    let re = /^(([^<>()[].,;:s@"]+(.[^<>()[].,;:s@"]+)*)|(".+"))@(([[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}])|(([a-zA-Z-0-9]+.)+[a-zA-Z]{2,}))$/;

    if ( re.test(email) ) {
        // this is a valid email address
        // call setState({email: email}) to update the email
        // or update the data in redux store.
    }
    else {
        // invalid email, maybe show an error to the user.
    }

}
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript binary to int 
Javascript :: regex valid day 
Javascript :: get the current url javascript 
Javascript :: jquery click on parent but not child 
Javascript :: get user language js 
Javascript :: uppercase angular pipe 
Javascript :: jquery select by data attribute 
Javascript :: react native text area form 
Javascript :: pass number as a prop in react 
Javascript :: set text of dom element 
Javascript :: javascript array of cumulative sum 
Javascript :: next js get current url 
Javascript :: js fake promise with timeout 
Javascript :: angular button open file input 
Javascript :: javascript change page title 
Javascript :: javascript get current date jalali 
Javascript :: javascript regular expression for alphanumeric 
Javascript :: javascript get base url 
Javascript :: enable version 12 node glitch 
Javascript :: js array enclose all items with ' 
Javascript :: preview image file upload javascript 
Javascript :: javascript add day to date 
Javascript :: javascript random boolean 
Javascript :: jquery select element with data 
Javascript :: let count = 0;console.log(parseInt("count"+ 1)); 
Javascript :: transformorigin gsap 
Javascript :: javascript convert number to string 
Javascript :: groupby javascript by instances 
Javascript :: mongoose connect database name 
Javascript :: hwo to create an array filled with sequencial numbers 
ADD CONTENT
Topic
Content
Source link
Name
6+7 =