Update validate-email.md
This commit is contained in:
@ -1,10 +1,11 @@
|
|||||||
### Validate Email
|
### Validate email
|
||||||
|
|
||||||
Regex is taken from https://stackoverflow.com/questions/46155/how-to-validate-email-address-in-javascript
|
Use a regular experssion to check if the email is valid.
|
||||||
Returns `true` if email is valid, `false` if not.
|
Returns `true` if email is valid, `false` if not.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const validateEmail = str => /^(([^<>()\[\]\\.,;:\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,}))$/.test(str);
|
const validateEmail = str =>
|
||||||
|
/^(([^<>()\[\]\\.,;:\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,}))$/.test(str);
|
||||||
// isemail(mymail@gmail.com) -> true
|
// isemail(mymail@gmail.com) -> true
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user