Expand my Community achievements bar.

SOLVED

validate required fields before using custom email button

Avatar

Former Community Member

Good Morning,

I have a custom button that I am using as a email button so we could have a cc address added. The code I'm using is:

form1.subform.Button3::click - (JavaScript, client)

var oDoc = event.target;
oDoc.mailDoc({
bUI: true,
cTo: "test@email.com",
cCc: "cc@email.com",
cSubject: "Title of the form",
});

Is there a way I can validate that 3 text fields are filled in when the user clicks the button?

Thank you for any help you can provide.

1 Accepted Solution

Avatar

Correct answer by
Level 10

to verify if a field is filled in you may use the if statement to check if the rawValue is null

if null is not working it might be because it's a checkbox or radiobutton or dropdownlist, etc... cehck if value is 0

Now when you are about to send the email verify is the fields were filled in successfuly

View solution in original post

2 Replies

Avatar

Correct answer by
Level 10

to verify if a field is filled in you may use the if statement to check if the rawValue is null

if null is not working it might be because it's a checkbox or radiobutton or dropdownlist, etc... cehck if value is 0

Now when you are about to send the email verify is the fields were filled in successfuly

Avatar

Former Community Member

Thank you it worked! Code used for reference:

var boValidation = true;

if (form1.subform.name.rawValue == null || form1.subform.userid.rawValue == null || form1.subform.compname.rawValue == null)

{

//Change validation to null

boValidation = false;

app.alert("Please fill in the required fields.");

}

if (boValidation)

{

var oDoc = event.target;

oDoc.mailDoc({

bUI: true,

cTo: "t...@domain.com",

cCc: "c...@domain.com",

cSubject: "title",

});

}