Skip to main content
Participating Frequently
March 28, 2022
Question

How to make a pop-up (app.response) where u can only fill in numbers?

  • March 28, 2022
  • 2 replies
  • 517 views

Below is a part of my code. I currently have the text added to the pop-up windows that asks the users only to fill in numbers, but I am sure a couple users will not read it well enough. So my question is, how can I make sure the users can only fill in numbers and not letters or other symbols in the response box? Thanks in advance.

 

if (global.fileCounter==null) {
var cRTN = app.response( {cQuestion:"Fill in the correct document number. ONLY USE NUMBERS",cTitle:"DOC-number",cLabel:"DOC-"});

 

 

 

 

This topic has been closed for replies.

2 replies

try67
Community Expert
Community Expert
March 28, 2022

You can't force them to only enter numbers. You can, however, validate what they entered and if it's invalid display an error message and stop the script from executing further.

Something like this:

 

if (cRTN==null || /^\d+$/.test(cRTN)==false) {
	app.alert("Invalid value.");
} else {
	// rest of code goes here
}
MaiaW
Participant
March 28, 2022

Hi Niels.

You can go into the field properties (select Prepare Form from the Tools menu) and change the filed's Format to "Number".  Similar to Excel you can, set the number of decimal places, seperator style, currency symbols, etc. and set the paramaters to your liking.

 

 I use this feature pretty often when creating forms for my department. Hope that helps! 😊

Always with gratitude.Máia
Participating Frequently
March 28, 2022

Hi, thanks but this is not what I meant. 

My script puts Bates numbers on multiple PDF-files at once, so a form will not work unfortunately. It has to be included in my code somehow.