These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Required Field - Pop-up Warning

markojett
Registered: Dec 21 2009
Posts: 22
Answered

I need to create a field that is required by the user, and if they tab or click out of this field, creates a pop-up that this "field is required". Is that even possible? Thanks again.

My Product Information:
Acrobat Pro 8.1, Windows
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
You can script an exit or on blur event to test for an entry or no entry.

You may also want to include code to test for this required data before printing, submitting, or saving and issue an appropriate waining.

George Kaiser

try67
Expert
Registered: Oct 30 2008
Posts: 2398
Accepted Answer
So on the OnBlur event you can use something like this (let's say the field is called "Text1"):
if (getField("Text1").value=="") app.alert("This field is required!");

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

markojett
Registered: Dec 21 2009
Posts: 22
Thank you - You've been a great help!!
Jamesone
Registered: Jul 31 2011
Posts: 15
gkaiseril wrote:
You can script an exit or on blur event to test for an entry or no entry.You may also want to include code to test for this required data before printing, submitting, or saving and issue an appropriate waining.
Hi George could you give an example of a script for before printing a form.

Thanks
try67
Expert
Registered: Oct 30 2008
Posts: 2398
With the document open, go to Advanced - Document Processing - Set Document Actions... then select Document Will Print and add the script to it.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

talontan
Registered: Oct 2 2011
Posts: 1
Great. It worked for me too as I was having a similar experience.

[url=http://www.workvacancies.net">Work Vacancies-Nigeria's Premier Job Portal[/url]
[url=http://www.workvacancies.net">Jobs in Nigeria[/url]

Jamesone
Registered: Jul 31 2011
Posts: 15
Here is another way of doing this which I found off the net and works well. Hope this helps someone, this is not my code....

Make a Print button on the form and add this to javascript action for print button.
validateFields();

GOTO Tools, document javascripts and add the following to a new script.

//-------------------------------------------------------------
//-----------------Do not edit the XML tags--------------------
//-------------------------------------------------------------

//
//validateFields
//
/*********** belongs to: Document-Level:validateFields ***********/
function validateFields()
{


//a counter for the number of empty fields
var flg = 0

// count all the form fields
var n = this.numFields

//create an array to contain the names of required fields
//if they are determined to be empty

var fArr = new Array();

//loop through all fields and check for those that are required
// all fields that have a '*' in their tool tip are required

for(var i = 0;i0){
app.alert('There are '+flg+' fields that require a value\n\n'+ fArr,3)
}
else{
this.print();
}

}
//
////
//print2:Annot1:MouseUp:Action1
//
/*********** belongs to: AcroForm:print2:Annot1:MouseUp:Action1 ***********/
validateFields();
//
//After doing this goto the Txt fields you want to be reminded to fill in and in the tooltip section place a * after any text you enter.

When you press the print button and the form is not filled in where you have placed the * in the tooltip a popup will come up telling you to fill in missing fields.
It will not print with the button until the form has been corrected.

The only problem I have found with this. Is that 0 is not a value and will ask that a number from 1 onwards needs to be placed in txt field.

Works great for me and will stop people printing forms out without filling them in correctly...