cancel
Showing results for 
Search instead for 
Did you mean: 

Check if fields in form is empty using a regular button..

Former Member
0 Kudos

Hi all,

I have a form and i need to ensure that all fields are being filled in when user clicks on a submit button.

I tried out using the SubmitEmail button and i was prompted to fill in the fields which i set to user entered required.

What i need now is when user clicks on the button submit, im supposed to check if all the fields are filled in, and IF all fields are filled in, it will run another set of codes done by my project mate which is to set all the fields to become "Protected".

Does anyone have any codes which can allow me to validate to check if all fields are not left empty, and then the codes needed for my IF ELSE statements?

example:

<>check if all fields empty --> if all fields filled in --> changes all fileds to "Protected"(i have the codes for making the fields protected)

<>check if all fields empty --> if empty --> prompt message/error and nth happens until user fill in the required fields and click on submit again.

Thanks In Advance

Regards,

JingXuan

Accepted Solutions (0)

Answers (2)

Answers (2)

i042339
Product and Topic Expert
Product and Topic Expert
0 Kudos

This can be easily handled using java scripts.

i042339
Product and Topic Expert
Product and Topic Expert
0 Kudos

There is some problem .. I am not able put the sample code.

I will try sometime later. i wrote around 50 lines but could not submit

i042339
Product and Topic Expert
Product and Topic Expert
0 Kudos

This can be easily handled using java script. You do not have to implement my earlier solution. No need to make the field as User Entered Required.

Please follow the steps mentioned below

Use 1 Regular button.

On Click event you can write java script to check whether the fields are filled or not

Please find the sample code attached with this mail.

var errorMessage = "";

var errFlag = 0;

if (xfa.resolveNode("pdfData.Field1").rawValue == null )

{

errFlag = 1;

errorMessage = errorMessage + "\n Field1 is empty";

}

if (xfa.resolveNode("pdfData.Field2").rawValue == null )

{

errFlag = 1;

errorMessage = errorMessage + "\n Field2 is empty";

}

If (errFlag = 1)

{

}

else

{

////// Do all your check

///// Then finally submit

////// Note that SubmitButton1 is a hidden Button

xfa.resolveNode("pdfData.Page2.Footer_Details.SubmitButton1").execEvent("click");

}

This will definitely help to proceed further.

Cheers

Satya

Former Member
0 Kudos

Hi Satya,

Wow its amazing! Im trying out the codes now, but just a few questions i wanna ask to confirm:

1) " (xfa.resolveNode("pdfData.Field1").rawValue == null ) " <-- What does the pdfData stand for? The name of my form? I know .Field1 is the name of the field that i wanna make sure it is filled, wad about pdfData?

2)" xfa.resolveNode("pdfData.Page2.Footer_Details.SubmitButton1").execEvent("click"); " <-- Again, what does this pdfData stand for?

So if the button is on the 1st page, it will be Page1 instead of Page2 right?

Footer_Details is the name of a subform? or?

Sorry for asking so much questions, once the code can work i'll award the points immediatly =DD

Thanks In Advance!

Regards,

JingXuan

i042339
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi,

That was just a sample code. you have put your own code instaed of that.

Just go to Menu bar -> Window -> Hierachy

Now you will see a pallet called Hierachy.

You have to get the node hiearchy from that.

Cheers

Satya

Former Member
0 Kudos

Hi Satya,

What i meant was wad does the pdfData represent, what should be the start of the sentence.

Do i start from Page1, start from my 1st Subform?

If lets say my hierarchy goes this way:

Page1

-Subform2[1]

--buttonForm

---SubmitButton

So do i start from Subform2[1] or buttonForm

Sorry >_<

Regards,

JingXuan

i042339
Product and Topic Expert
Product and Topic Expert
0 Kudos

Start from the root node in the hierarchy and move to the actual field (Text Field or Button).

RootNode -> page1 - > Field1 Similar to this... You check the Hierarchy pallete you will get clear idea.

Root Node is the node ... above the Node Master Pages Node.

Let me know if you are facing any problem.

Cheers

Satya

Former Member
0 Kudos

Hi Satya,

Oh okay i got it, but i im alittle puzzled as to this code:

////// Note that SubmitButton1 is a hidden Button

xfa.resolveNode("pdfData.Page2.Footer_Details.SubmitButton1").execEvent("click");

U said that the SubmitButton1 is the hidden button, but what is the exact purpose of this particular line of code? What does it do? Execute the check function?

Because Im supposed to let the user click on the 'Submit' button, check if all fields are not empty, only then once all fields are filled in will the hidden button be displayed. Im a little unsure why inside this code it involves the 2nd button(hidden button)

And using the codes that you provided me, i received a syntax error as shown:

" Error: Syntax error near token '{' on line 4, column 1. "

-


My Codes

var errorMessage = "";

var errFlag = 0;

if (xfa.resolveNode("Test.Subform2.Name").rawValue == null )

{

errFlag = 1;

errorMessage = errorMessage + "\n Name Field is empty";

}

if (xfa.resolveNode("Test.Subform1.GST").rawValue == null )

{

errFlag = 1;

errorMessage = errorMessage + "\n GST Field is empty";

}

If (errFlag = 1)

{

}

else

{

////// Do all your check

///// Then finally submit

////// Note that SubmitButton1 is a hidden Button

xfa.resolveNode("Test.Subform21.bttonForm.Button2").execEvent("click");

}

Thanks In Advance

Regards,

JingXuan

i042339
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi,

You can ignore that line of code.

Actually I have given you a sample code .. How you can call the click event of a hidden button from another button.

Later you may find this information useful.

Basically I am calling the Click event of another hidden button from the regular button where you are checking all the Mandatory fileds.

Cheers

Satya

Former Member
0 Kudos

Hi Satya,

Hahas, i managed to complete my function using another code my friend gave me.

if (Test.Subform1.Payee.isNull) {

xfa.host.messageBox ("Please complete your form!"); }

But thanks anyway satya 😃

Regards,

JingXuan

i042339
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi,

If you check my code .. I have given you the complete functionality...

I did not know that you have only one field which you want check..

I have given you the code which will work for multiple fields and prompt error message..

I have given you extended functionalities.. you have the choice of implementing the part of it..

Any way can you please close thread .

Cheers

Satya

i042339
Product and Topic Expert
Product and Topic Expert
0 Kudos

This is little tricky.. You have to use two submit button.

Just let me know what you want to do finally.

Are you going to submit the data to SAP. or this is a offline PDF.

Cheers

Satya

Former Member
0 Kudos

Hi Satya,

Ok this is what im trying to do.

Firstly, this form is being downloaded by a user offline, then user fills in the form at their own time and pace, once they filled up the form, they are supposed to submit the form online(this part is still under planning phrase).

But in general, my part now and the important part of this button is..

1. Check if form is filled.

2. If filled, we have an invisible button which will appear to allow user to do the final submission, and at the same time, all fields are to be set to read only.

The main problem for me now is writing the IF ELSE Statement and the codes to check if fields are being filled or left empty upon clicking on the button. Whereas the codes to set fields to readonly we have done that already 😃

Thanks In Advance

Regards,

JingXuan