Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.
SOLVED

Pop-up with conditions

Avatar

Level 7

HI again everyone!

Is it posible when in a numeric field(9 digits allaw) the first entered numbers are 202 a pop-up warning to come up(Please copy to...).

Thanks

1 Accepted Solution

Avatar

Correct answer by
Level 10

If you want the popup to display only once, then place the below code in the exit event of the NumericField.

var

strNewtext = NumericField1.rawValue.toString();

if

(strNewtext.length>3){

     if(strNewtext.substring(0,3)=="202")

          xfa.host.messageBox("This number is starting with 202");

}

Thanks

Srini

View solution in original post

8 Replies

Avatar

Level 10

xfa.event.newText command will give you the text of the field. Use that command in the Change event of the control.

Then use substring command in java script to verify the first 3 digits and display a messagebox if it meets your criteria.

Thanks

Srini

Avatar

Level 7

If you give me a little more help I will appreciate very much!

I am not a programmer to write the script I need...

Thanks very much for all your help

Avatar

Level 10

Try putting the following code in the change event of the numeric field.

var strNewtext = xfa.event.newText;

if(strNewtext.length>3){
     if(strNewtext.substring(0,3)=="202")
          xfa.host.messageBox("This number is starting with 202");
}

Thanks

Srini

Avatar

Level 7

Thanks for your help Srini, I really appreciate!

My numerical field requires 9 digits, and the problem I have with your script any time I enter digit after the third one the pop-up repeat and repeat again.

Any solution?

Thanks for your time

Avatar

Correct answer by
Level 10

If you want the popup to display only once, then place the below code in the exit event of the NumericField.

var

strNewtext = NumericField1.rawValue.toString();

if

(strNewtext.length>3){

     if(strNewtext.substring(0,3)=="202")

          xfa.host.messageBox("This number is starting with 202");

}

Thanks

Srini

Avatar

Level 10

Thank you..

If you feel your question is answered, then you can click on the Answered button. So that this thread will be moved to the closed threads.

Otherwise it will be in the open thread state.

Thanks

Srini

Avatar

Level 7

Hi Srini,

here is the script I use for a email button:

form1.Sub_All.Sub_4.Footer.Mail::click - (JavaScript, client)

if(Init.Ex1ValidFields())

var myDoc = event.target;    
var address = "xxx@xxx.org";     
var sub = "Maintenance  Form";    
var msgBody = "See my Maintenance Requisition Form attached.\n\nThank You!";
var Sender = form1.Sub_All.Sub_2.Department.rawValue; 

myDoc.mailDoc({ bUI: false,        
cTo: address,
cSubject: sub + Sender,        
cMsg: msgBody + "\n\nRegards\n" + Sender,        
cSubmitAs: "PDF"});

What will be the addition for a pop up mesage (Please copy Jack London on the Requisition email), in case a numeric field(requires 9 digits) starts with 202?

Thanks