Skip to content

Instantly share code, notes, and snippets.

@gchriswill
Last active August 29, 2015 13:57
Show Gist options
  • Save gchriswill/9717605 to your computer and use it in GitHub Desktop.
Save gchriswill/9717605 to your computer and use it in GitHub Desktop.

Revisions

  1. gchriswill renamed this gist Sep 8, 2014. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. gchriswill revised this gist Mar 23, 2014. 1 changed file with 9 additions and 7 deletions.
    16 changes: 9 additions & 7 deletions JS_emailStringValidation.js
    Original file line number Diff line number Diff line change
    @@ -1,17 +1,19 @@

    //Save the value of the field into a variable
    var emailValue = emailField.getValue();

    /* This formula or method condition first searches for if there is an "@" in the string
    * Then is searches for if there is more than one "@" symbol
    * Then checks if the subdomain area is less than 4 characters
    * Then checks if the last "." is after the "@" and 3 spaces after the "@"
    * Then checks if there are two or less characters after the last "."
    /* This formula or method condition in five easy steps
    *
    * 1- First searches for an "@" in the string
    * 2- Then it checks for more than one "@"
    * 3- Then checks if the subdomain area is less than 4 characters
    * 4- Then checks if the position of the last "." is less than 3 spaces after the "@"
    * 5- Then checks if there are two or less characters after the last "."
    */

    if ( ( emailValue.search("@") == -1 ) || ( emailValue.indexOf("@") !== emailValue.lastIndexOf("@") ) || emailValue.indexOf("@") < 4 || emailValue.lastIndexOf(".") < emailValue.indexOf("@") + 3 || emailValue.lastIndexOf(".") + 2 >= emailValue.length )
    {

    alert("Please enter a valid email")
    alert("Please enter a valid email");

    };

  3. gchriswill renamed this gist Mar 23, 2014. 1 changed file with 7 additions and 6 deletions.
    13 changes: 7 additions & 6 deletions JS_emailStringValidation → JS_emailStringValidation.js
    Original file line number Diff line number Diff line change
    @@ -1,12 +1,13 @@

    //Save the value of the field into a variable
    var emailValue = emailField.getValue();

    //This formula or method condition first searches for if there is an "@" in the string
    //Then is searches for if there is more than one "@" symbol
    //Then checks if the subdomain area is less than 4 characters
    //Then checks if the last "." is after the "@" and 3 spaces after the "@"
    //Then checks if there are two or less characters after the last "."

    /* This formula or method condition first searches for if there is an "@" in the string
    * Then is searches for if there is more than one "@" symbol
    * Then checks if the subdomain area is less than 4 characters
    * Then checks if the last "." is after the "@" and 3 spaces after the "@"
    * Then checks if there are two or less characters after the last "."
    */
    if ( ( emailValue.search("@") == -1 ) || ( emailValue.indexOf("@") !== emailValue.lastIndexOf("@") ) || emailValue.indexOf("@") < 4 || emailValue.lastIndexOf(".") < emailValue.indexOf("@") + 3 || emailValue.lastIndexOf(".") + 2 >= emailValue.length )
    {

  4. gchriswill renamed this gist Mar 23, 2014. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion JSemailStringValidation → JS_emailStringValidation
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,8 @@ var emailValue = emailField.getValue();
    //Then is searches for if there is more than one "@" symbol
    //Then checks if the subdomain area is less than 4 characters
    //Then checks if the last "." is after the "@" and 3 spaces after the "@"
    //Then checks if the
    //Then checks if there are two or less characters after the last "."

    if ( ( emailValue.search("@") == -1 ) || ( emailValue.indexOf("@") !== emailValue.lastIndexOf("@") ) || emailValue.indexOf("@") < 4 || emailValue.lastIndexOf(".") < emailValue.indexOf("@") + 3 || emailValue.lastIndexOf(".") + 2 >= emailValue.length )
    {

  5. gchriswill created this gist Mar 23, 2014.
    15 changes: 15 additions & 0 deletions JSemailStringValidation
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    //Save the value of the field into a variable
    var emailValue = emailField.getValue();

    //This formula or method condition first searches for if there is an "@" in the string
    //Then is searches for if there is more than one "@" symbol
    //Then checks if the subdomain area is less than 4 characters
    //Then checks if the last "." is after the "@" and 3 spaces after the "@"
    //Then checks if the
    if ( ( emailValue.search("@") == -1 ) || ( emailValue.indexOf("@") !== emailValue.lastIndexOf("@") ) || emailValue.indexOf("@") < 4 || emailValue.lastIndexOf(".") < emailValue.indexOf("@") + 3 || emailValue.lastIndexOf(".") + 2 >= emailValue.length )
    {

    alert("Please enter a valid email")

    };