Expand my Community achievements bar.

Need script to force text entry

Avatar

Level 2

I have

a form that I need to require that two text fields be

user entered before they click my email send button. I am

not using a submit buttun. Is there a script that I can use to stop them if they do not enter some text in those two fields?

8 Replies

Avatar

Former Community Member

If you are not using a submit button how are you generating the email?

Paul

Avatar

Level 2

A click event with java and a button. It works very well

var oDoc = event.target;

oDoc.mailDoc()

Avatar

Former Community Member

Set the fields that you want to force to be filled as User Entered Required (on theObject/Value tab under the TYpe dropdown). This makes the fields required. Now modify the code on your email button to do this:

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

     var oDoc = event.target;
      oDoc.mailDoc()
} else {
      app.alert("There are mandatory fields not field yet!")

     app.runtimeHighlight = true;
}

Where form1 is the root node (in the hierarchy of your form). In the else portion I put a message box there just to show you how it works. Note that the product will generate a default message as well. The app.runtimeHighlight will turn on the field highlighting and will mark and required field in a red border.

Paul

Avatar

Level 2

if (Page1.execValidate() == true){

var oDoc = event.target;

oDoc.mailDoc()

} else {

app.alert("There are mandatory fields not field yet!")

app.runtimeHighlight = true;

}

bUI: true,

cTo: "customerservice@jobesvcs.com",

cMsg: "These are Invoices & Schedule sent from Client#

"form1.Page1.Header.ClientId.rawValue","

form1.Page1.Header.ClientName.rawValue","+" With a schedule date of "

+form1.Page1.Footer.ScheduleDate.rawValue,

cSubject:"Client ID = " + form1.Page1.Header.ClientId.rawValue,

})

app.execMenuItem("Close");

This is my entire script

Avatar

Level 2

I was given an error saying

Invalid Label

Avatar

Level 2

Great, I had a little code wrong....Thanks for the great help, it works

Avatar

Level 2

I have a date field that is a calculate java event that is throwing me a

curve. It is suppose to populate the current date if the field is empty.

When I open the form online it is saying 4-29-11 but when I click my add new

instance of the invoice it populates the field with 4-30-11 which is

correct. I opened the form off line and it populated the field with 4-30-11

when it opens. Here is the code;

if (this.rawValue == null){

var msNow = (new Date()).getTime();

var d1 = new Date(msNow);

this.rawValue = util.printd("mm/dd/yy", d1); } else { this.rawValue =

rawValue;

Can you see what may be wrong here?

Steve