Skip to content

Instantly share code, notes, and snippets.

@dave-jay
Created November 23, 2015 17:32
Show Gist options
  • Select an option

  • Save dave-jay/cc9976ca0c9fada59e49 to your computer and use it in GitHub Desktop.

Select an option

Save dave-jay/cc9976ca0c9fada59e49 to your computer and use it in GitHub Desktop.

Revisions

  1. dave-jay created this gist Nov 23, 2015.
    31 changes: 31 additions & 0 deletions phone_validatin.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    if (theType == 'Phone') {

    if(theFieldValue.charAt(0) == '1'){
    alert("The number should not start with 1");
    return false;
    }

    if (theFlag) {

    // Required Entry

    theRE = eval("/^[0-9]{10,10}$/");

    } else {

    theRE = eval("/^$|^[0-9]{10,10}$/");

    }

    if (theRE.test(theFieldValue)) {

    } else {

    alert("Must be ONLY 10 number digits with no prefix. Area code and numbers only..");

    eval(theField + ".value = ''");

    retVal = 0;

    }
    }