Home / Free JavaScripts / Email and Email Validation / Here

Cut & Paste Advanced Email Check plus screening out of certain types of addresses

Credit: JavaScript Kit

Description: A script that closely examines the content of a form box to ensure that the user entered a valid email address. If not, the form submition is canceled, and the surfer prompted to re-enter a valid address. If it is, the script continues and checks whether the address is of a certain type (such as hotmail and yahoo), and if it is, blocks the form submition as well. In essense, this script allows you to not only block invalid email addresses, but "casual" addresses as well. The script makes the following assumptions regarding what a valid email address is:

-Contains a least one character procedding the "@"
-Contains a "@" following the procedding character(s)
-Contains at least one character following the "@", followed by a dot (.), followed by either a two character or three character string (a two character country code or the standard three character US code, such as com, edu etc)

Note that this script requires NS 4+ or IE 4+ to function- all other browsers will simply not participate in the form validation process.

(Entering is ok, whereas bad@something and are not)

Please input a valid email address:

Directions: Simply cut and paste the below code into the <body> section of your page. It
contains a form with one box that is checked for "email validity". You can add in more form elements into the form, as you would with any other form.

The type of addresses that are to be blocked are contained inside the array "invalidaddress". Change those to your own. Note that the message that will be alerted when a user enters one of these email addresses is "Please input a more official email address!" You may wish to change that message.

JavaScript Tools:
Site Info

CopyRight (c) 2018 JavaScript Kit. NO PART may be reproduced without author's permission. Contact Info