1 Reply Latest reply on Apr 24, 2015 1:51 PM by try67

    Enforce custom email address, field cannot be blank

    3nascar

      I am preparing forms and want to require only the school email is entered. I am currently using the default javascript for email validation, but would like to enforce the email end with @school name.edu, and field cannot be left blank. 

      I am using the onblur action. Here is what I currently have which gives a fill-in box if they try to leave the field empty, but still allows them to put in a personal email address and they can hit the cancel key and move to the next field leaving the email field blank. I know I am missing something.  Am new to javascript so any help would be appreciated.  Using Acrobat XI Pro

       

      // report error if there is an invalid email address when the field is not empty.

      if (! eMailValidate(event.value) && event.value != "")

      {

      event.rc = false;

      app.alert({

      cMsg: "Invalid email address - Please try again",

      nIcon: 0,

      nType: 1

      });

      } // end if validation test

      var t = event.target;

      var cResponse = app.response({

      cQuestion: "Type your University email address",

      cTitle: "Universityemail",

      cDefault: "email not added",

      cLabel: "Type your University email"});

      {

      if (cResponse == null) { //if cancel is selected

      app.alert ("You cancelled adding your email?");

      cResponse = "";

      }

      else

      app.alert ("You typed your email as: \""+cResponse+"\" \n\n Tab out of the field to register your email",2);

      }

      t.value = cResponse; //places the data from the dialog to the target field