Skip to main content
giveawayer
Known Participant
May 16, 2021
Answered

Enforcing stamp input, Text field validation, and a few other questions about text fields

  • May 16, 2021
  • 1 reply
  • 1289 views

Hi,

 

My stamp has 6 text fields: name, date, project (optional), submittal number (optional), scope, notes.  When the stamp is placed the user dialog appears with both the name and date already populated.  Project and submittal num are optional, so I need to require the user enter text in either Scope or Notes.  

My goal is to:

--Prevent the stamp from being placed if no data was entered in the dialog.  So if the user did not enter text in Scope or Note, yet click the Ok button, they're alerted and the dialog box reappears so the user can completely fill out the dialog.

Also, I'd like to

--Hide the optional fields on the stamp if no data was input by the user. 

--Allow the Notes text to be copied and pasted after creating the stamp (so we can reuse the note text) --but not editable on the stamp--.

 

I placed the below in the script before the getField statements, but it doesn't work.  Can you help? 

   

function checkText()
{
var showText1 = document.getElementById("sco1").value;
{
if(showText1.value ="")
alert('please enter text into sco1');
alert('my message...');

}

}

 

This topic has been closed for replies.
Correct answer try67

No, it should be under the validate function of the dialog object. It needs to return false if you want the dialog to remain open. See the documentation of the execDialog method.

1 reply

try67
Community Expert
May 16, 2021

--Prevent the stamp from being placed ...

You can't prevent the file from being placed, but you can prevent the dialog box from closing enter the user entered all the required values. Use the validate function of the dialog object for that.

 

--Hide the optional fields on the stamp if no data was input by the user.

Set them as hidden by default and show them when needed, by setting their display property.

 

--Allow the Notes text to be copied and pasted after creating the stamp (so we can reuse the note text) --but not editable on the stamp.

Once a stamp is applied you can't edit the text in it. However, you also can't copy it, at least not directly. In order to do that you have to first flatten it, and then you'll be able to copy the text that it had.

giveawayer
Known Participant
May 17, 2021

Yes.  I'd like to prevent the dialog box from closing, alert the user to enter data in all required fields, then return them to the dialog box so that they can properly fill it out.

Can you provide an example?  And should this script be in the "Custom calculation script"? Or the "Run custom validation script" of one of the form fields? 

try67
try67Correct answer
Community Expert
May 17, 2021

No, it should be under the validate function of the dialog object. It needs to return false if you want the dialog to remain open. See the documentation of the execDialog method.