Hi everyone someone left at job and I fall with the job of finishing all PDF form.
I am trying to build the simplest code possible, I found this on the internet
var Q = this.getField("topmostSubform[0].Page1[0].NumericField25[0]").value;
function checkscript()
{
app.alert("Check");
if (Q =="")
{
app.alert("You must fill in all required fields before submitting Vous devez remplir les champs obligatoire avant de soumettre le document");
return false;
}
else if (Q !="");
{
alert("Check");
return false;
}
return true;
}
- First problem is I do not know to use function, how do I check the value returned ?
Right now this function does not work at all I am really newbie!!!
I just want to verify one field !!!!!
- Second probleme, I have build little code for checking emtpy field on another form, for validation, the code is working see below.
var Q = this.getField("topmostSubform[0].Page1[0].Course_Title_Titre_du_cours[0]").value;
var R = this.getField("topmostSubform[0].Page1[0].StartDate_YYYYMMDD[0]").value;
var S = this.getField("topmostSubform[0].Page1[0].PRI_CIDP[0]").value;
var T = this.getField("checkbox1").value;
var V = this.getField("checkbox2").value;
var U = this.getField("topmostSubform[0].Page1[0].EndDate_FindeCours_YYYYMMDD[0]").value;
var W = this.getField("justifi").value;
W = X;
if (((U =="") || (Q =="")) || ((R =="") || (S =="")) ||((T == "Off") && (V == "Off")))
{
app.alert("You must fill in all required fields before submitting Vous devez remplir les champs obligatoire avant de soumettre le document");
}
elseif
{
app.alert("You must fill in all required fields before submitting Vous devez remplir les champs obligatoire avant de soumettre le document");
}
It is not really nice I know but it works.
The probleme with that one is if I verify if a text field is empty, I do not know how to update the variable so, somone is entering text in the text box and my validation code does not know that the box is not empty anymore, I switch to design mod and come back and the validation works because the value has been pass to the variable and the validation is working. Trivial stuff I know, but i just jump onto that stuff 48 hours ago.
If someone can fix my error or sent me a link for good working example, and basic tutorial, cause I am waiting my time.
Thanks in Advance
Daniel
It appears that you have a LiveCycle form? The "this.getField()" function is in the AcroForm API. It will work on a Static LiveCycle form, but it only works because there is some symmetry between the structure of an AcroForm and a Static LivCycle form. It is not accessing the field data in the correct way, and may break in a future update.
I'm actually surprised that it is working at all because "this", in a LiveCycle context, points to the local DOM element, not the doc object. In what context is this code being run? If it is working then it's being run outside the XFA context or you have a LiveCycle form that has been hacked into an AcroForm.
If all you are looking for is empty field detection on submit then the easy solution is to make the fields required. If you are looking at some other kind of form level validation then do a search on this site on the word "form validat" Filter for tutorials and forum messages. There's a ton of information.
Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script