Skip to main content
Participant
December 17, 2024
Answered

Limit the inputs in a text box

  • December 17, 2024
  • 2 replies
  • 404 views

Hi, I am new into pdf java script. Is there a way that I can restrict the user to input only ".5", ".75", and whole numbers only. I have searched community discussions but suggestions are not working to what I want to achieve.

 

Like the input can only be:

0.50

0.75

1.00

1.50

1.75

or 2.00

This topic has been closed for replies.
Correct answer PDF Automation Station

Enter the following custom validation script:

event.rc=true;
if(!(event.value%1==0||event.value%1==.5||event.value%1==.75))
{
app.alert("Number must be a whole number or end with 0.5 or 0.75.");
event.rc=false;
}

2 replies

PDF Automation Station
Community Expert
Community Expert
December 17, 2024

Enter the following custom validation script:

event.rc=true;
if(!(event.value%1==0||event.value%1==.5||event.value%1==.75))
{
app.alert("Number must be a whole number or end with 0.5 or 0.75.");
event.rc=false;
}
BSI13Author
Participant
December 18, 2024

Thank you @PDF Automation Station . That worked like magic. Just the way I want it. I have been trying different scripts and computations with so much conditions to achieve this and you just made that easy four lines.