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

Submit button validating for null test

contesa
Registered: Mar 8 2010
Posts: 17

I have a Required date field that is scripted to alert user if correct date format isn't used and the focus stays on the field until the correct date format is entered. The user cannot tab out of field or submit form if he has clicked on field and hasn't entered a correct date. However, if the user doesn't click in the field the validations do not work and user is able to Submit form.

How do I script Submit button to check field for data prior to submitting form.

The submit is emailing form as "pdf" to set email address.

My Product Information:
LiveCycle Designer, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
There are two types of validation, Field level and Form level. The validation script is for field level validation. It's run only when the user enters data into the field and its purpose is to ensure correct data is entered. Form level validation is run when the form is submitted and it's purpose it to ensure the correct fields are filled out. Forms have an automatic form level validation feature that is enabled by setting a field as Required. Is the date field marked as Required? Can you post the validation script?

You can read more about validation strategies here:
http://www.pdfscripting.com/public/department46.cfm

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

contesa
Registered: Mar 8 2010
Posts: 17
The field is marked as "Required". Here is the validation script I am using on the Click event of the Submit Button:

function ValidateForm(DICE)
{
if(IsEmpty(DICE.CEB_DICE_INCIDENTS.REPORT_DATE))
{
alert('You have not entered a DATE SUBMITTED')
DICE.CEB_DICE_INCIDENTS.REPORT_DATE.focus();
return false;
}

return true;

}

I am also using the following on the MouseDown event of the same Submit button:

event.target.submitForm({cURL:"mailto:dice [at] nj [dot] org?subject=D.I.C.E. Submission Form&body=D.I.C.E. Submission Form attached.",cSubmitAs:"PDF",cCharset:"utf-8"});On the Required date field I have the following script on the Exit event:

if

(this.rawValue == this.formattedValue)

{

app.alert("Please use the calandar or enter a date in 'MM/DD/YYYY' format");

xfa.host.setFocus(this.somExpression);this.rawValue


="";

}

if(!(this.rawValue))
xfa.host.setFocus(this.somExpression);
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
The mouseDown event is called before the click event. In this case you should only be using one. And, if the intention is to block submission using the script, then the submitForm() call has to be quaified with the validation test. Otherwise, if you intent to use the built-in null test, then a submit action has to be used. I believe I wrote an article on this. search the JavaScript tutorials for "submit"

For field level validation do not use the exit event. Use the validate event.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

contesa
Registered: Mar 8 2010
Posts: 17
Hi Thom,

Finished off my function:

if(this.rawValue == this.formattedValue) {
app.alert("Please use the calandar or enter a date in 'MM/DD/YYYY' format");
xfa.host.setFocus(this.somExpression);
this.rawValue="";
}
else {
Button5.access = ""}

if(!(this.rawValue)) xfa.host.setFocus(this.somExpression);

and removed the click event script.

Made Submit button read only and added alert on initialization advising user the Submit button will not work until required information has been entered.
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Does it work?

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

contesa
Registered: Mar 8 2010
Posts: 17
Yes, when the form loads the Submit button does not work. Once the correct information has been entered into the Date field and the field loses focus, the Submit button is available.