Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events

Trying to set titlefield to mandatory if namefield is not null in Livecycle Designer

Avatar

Level 1

I have a form that is used to list employees being added to a database.  They can enter from 1-10 employess per form.  For each line of the form, if the name field is entered (not null), i want the title field to become mandatory, and for the form to not submit.

The following code is in the 'exit' event of the name field.  It does in fact set the title field to mandatory and highlight in red, however when i click the submit button, it seems to override the code.  The form still allows for submit, and the red highlight disappears.  

Any clues?

if ((Text_Name1.rawValue != null) || (Text_Name1.rawValue != ""))

{

     Text_Title1.mandatory = "error";

}

else

{

     Text_Title1.mandatory = "disabled";

}

Ok i need to mention i also have javascript in the 'click" event of my Submit Button that allows me to "mailto" email address located within text fields of my form. 

var eadd = "";

var cadd = "";

var ebody = "";

eadd = Text_EmailTo.rawValue;

cadd = Text_EmailCC.rawValue;

event.target.submitForm({cURL:"mailto:"+eadd+"?cc="+cadd+"&body=" +ebody,cSubmitAs:"PDF",cCharset:"utf-8"});

If i remove this code, my mandatory field issue resolves.  Is there something in my submit button script that would override the script in my text field? 

3 Replies

Avatar

Level 6

If the button type is "HTTP Submit Button"/"Email Submit Button", it checks for any required fields are missed before it submits.

If the button type is "Button" we need to put the script on click event to check is the required fields are having data and proceds to submit.

-Raghu.

Avatar

Level 1

It is a regular "button". So do you mean to put the code in the click

event of my name field, or add it to the click event of my button? I tried

both and was still able to submit the form with an empty field.

If it belongs in the button click event, do i need to put something between

my two scripts to seperate them?

Thanks....sorry i'm a newb at javascript, obviously.

On Fri, Jan 11, 2013 at 12:13 PM, Raghu Nagireddy

Avatar

Level 6

Yes you need custom script on the click event of button. Also can restrict the user while fill the name and title. In this case no check required on the button.

Method1: Restrict while enter the data on name and title itself.

Uncomment the script on "Title" field and comment the script on "Button".

Method2: Check the required field and alert the same on submit action.

comment the part of the script on "Title" field and have the script on "Button".

Please check the form in the below URL, Both the above methods are implemented on form. used table for these field, can be modified as subform with fields if need.

https://workspaces.acrobat.com/?d=oPyj9JECQlDeZcfPtQQ2LQ

Hope this helps.