Expand my Community achievements bar.

xfa.host.response

Avatar

Former Community Member
Ok, I think I know what I am doing, keyword is THINK.

My code is:

EmplNum.rawValue = xfa.host.response("Please enter the first four numbers of your Employee Number");

InvName.rawValue = xfa.host.response("Please enter your initials");

datenum.rawValue = xfa.host.response("Please enter the date as - mmddyy");

var InvestN = String(InvName.rawValue);

var Emp_ID = String(EmplNum.rawValue);

var DateN = String(datenum.rawValue);

var INNum = Emp_ID+DateN+InvestN;

INum.rawValue = INNum



the code works great, pulls in the info into hidden fields then puts into the Investigation Number.



My question is: how to make sure the user only enters what is required. Meaning only four numerals, three letters, and six numerals.

I need help in the validation script area on how to validate the fields entered in the response dialog.
4 Replies

Avatar

Level 5
key here is recall the same response statement till you get the right data. Down side of this is user can not skip the JavaScript window till he/she provide right data for each of those responses.



Here is some sample from one of my forms to get Employee number when they open the form. You have to customize the code to your situation like in your situation you may have to use

var empnumPat = /^(\d{4})$/;



restrict the size and type of data with use of patterns.



on docOpen event of the field:



getEmpDetaiuls();



function getEmpDetaiuls() {



var empnum = xfa.host.response("Please enter your Employee Number.","Employee#","",false);

empnum = trim(empnum);

//xfa.host.messageBox(""+empnum);

if (empnum == "") {

//xfa.host.messageBox("Since you are not signed-in you can continue fill-in the form but no email Conformation will be received at Submit.");

xfa.host.messageBox("Sign-in with Emp# is required to complete and submit this Request.");

//loginFailed(); //to lock all fields since login failed

reCallgetEmpDetaiuls();

}else {

var empnumPat = /^(\d{1,})$/;

var matchArray = empnum.match(empnumPat); // is the format ok?

//xfa.host.messageBox(""+matchArray);

if (matchArray == null) {

//xfa.host.setFocus(this.name);

reCallgetEmpDetaiuls();

}else {

//check the number is valied in the HR database....

CUE_CompPass.SubmitSub.SubmittingEmp.rawValue = empnum;

//xfa.host.messageBox("hi");

var makesure = getLogedEmpDetails("Referral_Emp_Info", empnum);

//xfa.host.messageBox(""+makesure.value);

}

}

}



function reCallgetEmpDetaiuls() {

app.alert("A valid Employee number is required to continue.");

getEmpDetaiuls();

}



function trim(str)

{

return str.replace(/^\s*|\s*$/g,"");

}

Avatar

Former Community Member
I have used the sample code you sent and made it my own, but I can't figure out how to incorporate all three fields into one function. Right now I have three functions to handle the three responses from the user. Do I need to use these inside one function? Confused again.

Avatar

Former Community Member
Ok I have got the three responses fixed and the date vaildation fixed, I can't figure out for the life of me how to Vaildate the user Initials. I need to get a validation pattern for just three letters only no numbers, spaces, or anything else just the three initials.

Someone please help!!

Avatar

Former Community Member
I have a vital form that clients fill out, which is passed to many people in the company along the workflow. The form is a Planner and we have in the following PDF, Word Doc..



Well before, the Planner.pdf was originally created in Word, since most people have access to Word.. but evolved to a PDF form created from the Word Doc via Adobe LiveCycle Designer 8.0 w/ User Rights enabled so that the form could be filled out and saved using Adobe Reader.. which was a step better than Word.. being that it is free. But this needed to be easier and more to the point b/c some clients don't particularly like installing the latest version of Reader, even if you provide them the link. Nor do they like saving the form, filling the form, and attaching the form to send back.



My goal is to have the client fill an HTML version of the form, submit and be done with it, but everyone in the workflow be able to easily receive the filled Planner as a PDF form.



So some months ago I ran into this post Chris Trip, "Populate Livecycle PDF from mySQL database using PHP" #8, 22 Sep 2007 4:37 pm



which uses the command line Win32 pdftk.exe to merge an FDF file into an existing PDF on the remote server, and serve this to whoever.



My problem was with shared hosting and having the ability to use the Win32 pdftk.exe along with PHP which is predominantly used on Linux boxes. And we used a Linux box.



so i created the following unorthodox method, which a client fills the HTML version of the Planner, all field values are INSERTED into a table in MySQL DB, I and all filled planners that have been filled by clients to date can be viewed from a repository page where an XML file is served up of the corresponding client, but someone would have to have Acrobat Professional, to import the form data from the XML file into a blank form.. altoughh this is simple for me.. I have the PHP file already created so that when a Planner is filled and client submits. >> the an email is sent to me with a table row from the repository of the client name, #, email, and a link to d-load the XML file,



But I also have the PHP files created so that the Planner can be sent to by email to various people in the workflow with certain fileds ommitted they they do not need to see, but instead of the XML file beiong served up i need the filled PDF Planner to be served.



I can do this locally with ease on a testing server, but I am currently trying to use another host that uses cross-platform compatibility so i can use PHP and the pdftk.exe to achieve this, as that is why I am having to serve up an XML file b/c we use a Linux server for our website, and cant execute the exe.



Now that I am testing the other server (cross-platform host), just to use them to do the PDF handling (and it's only $5 per month) I am having problems with getting READ, WRITE, EXECUTE permissions..



Si guess a good question to ask is can PHP do the same procedure as the pdftk.exe, and i can eleminate it.



or how in the heck can i get this data from the DB into a blank PDF form, like i have described??



here are some link to reference



Populating a LiveCycle PDF with PHP and MySQL

http://www.andrewheiss.com/Tutorials?page=LiveCycle_PDFs_and_MySQL



HTML form that passed data into a PDF

http://www.mactech.com/articles/mactech/Vol.20/20.11/FillOnlinePDFFormsUsingHTML/index.html

and an example

http://accesspdf.com/html_pdf_form/

________________________________________