Skip navigation
Currently Being Moderated

Verify e-mail address field is not null.

Mar 29, 2012 11:11 AM

I am trying to get the script below to verify the "ReleasedIntoSystemBy" field (drop-down with email address values) is not blank. What have I got wrong?

 

 

// Declare the variable
var vEmail;
var vSubject = "New Work Order/Project Authorization"
var vBody = "Instructions:"

// Check that the email field is not null
if (xfa.resolveNode("#subform[0].#subform[2].Table111[1].Row1.ReleasedIn toSystemBy").rawValue !== null) {
     vEmail = xfa.resolveNode("#subform[0].#subform[2].Table111[1].Row1.ReleasedInt oSystemBy").rawValue;
}

// Send email
event.target.submitForm({cURL:"mailto: " + vEmail + "?subject=" + vSubject + "&body=" + vBody,cSubmitAs:"PDF",cCharset:"utf-8"});

 
Replies
  • Currently Being Moderated
    Mar 29, 2012 11:25 AM   in reply to DKinsley

    The script looks correct however, you are doing //Send Email script whether or not the vEmail value is null as it lies outside the if statement

     

    I''m assuming you want to send if vEmail is not null.  If that is the case then place the //Send Email script within the if statement.

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 29, 2012 11:36 AM   in reply to DKinsley

    Here you go

     


    // Declare the variable
    var vEmail;
    var vSubject = "New Work Order/Project Authorization"
    var vBody = "Instructions:"

    // Check that the email field is not null
    if (xfa.resolveNode("#subform[0].#subform[2].Table111[1].Row1.ReleasedIn toSystemBy").rawValue !== null) {
         vEmail = xfa.resolveNode("#subform[0].#subform[2].Table111[1].Row1.ReleasedInt oSystemBy").rawValue;
         // Send email
    event.target.submitForm({cURL:"mailto: " + vEmail + "?subject=" + vSubject + "&body=" + vBody,cSubmitAs:"PDF",cCharset:"utf-8"});
    }else{
    //displays message box warning user to fill in field

    xfa.host.messageBox("Please fill the email field");

    //sets the focus to the field
    xfa.host.setFocus(xfa.resolveNode("#subform[0].#subform[2].Table111[1 ].Row1.ReleasedIntoSystemBy"));

    }

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 29, 2012 12:26 PM   in reply to DKinsley

    if you execute the below script it will check all validations on the form such as required fields

     

    xfa.form.form1.execValidate()   

     

    form1 being the top node of you hierarchy

     

    it will return a true or false, true if validatations are all fullfilled or false if not

    In your script you could add an if statement similar to this

     

     

    if(xfa.form.form1.execValidate() == true){

      //within here execute your above email script

    }

     

     

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points