functioncheckEmail(){var email =document.getElementById('txtEmail');var filter =/^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;if(!filter.test(email.value)){alert('Please provide a valid email address');
email.focus;returnfalse;}}-Call the function on Email textbox
/**
* verifie si la chaine renseigné est un email
* check if email is valide
* @paramstring emailAdress
* @return bool
*/functionisEmail(emailAdress){let regex =/^w+([.-]?w+)*@w+([.-]?w+)*(.w{2,3})+$/;if(emailAdress.match(regex))returntrue;elsereturnfalse;}//see https://regexr.com/3e48o for another exemple
functionvalidateEmail($email){var emailReg =/^([w-.]+@([w-]+.)+[w-]{2,4})?$/;return emailReg.test( $email );}if(!validateEmail(emailaddress)){/* do stuff here */}
const 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,}))$/;functionApp(){const[email, setEmail]=React.useState({error:false,value:""});consthandleChange=(e: any)=>{// Trim value & convert to lowercaseconst value = e.target.value.trim().toLowerCase();// Test if email is validconst isValidEmail = re.test(value);setEmail({
value,error:!isValidEmail
});};return(<><input placeholder="Email" onChange={handleChange}/>{email.error&&<p>Please enter a valid email address.</p>}</>);}
<script>functionvalidateform(){var name=document.myform.name.value;var password=document.myform.password.value;if(name==null|| name==""){alert("Name can't be blank");returnfalse;}elseif(password.length<6){alert("Password must be at least 6 characters long.");returnfalse;}}