Expand my Community achievements bar.

July 31st AEM Gems Webinar: Elevate your AEM development to master the integration of private GitHub repositories within AEM Cloud Manager.

Checkbox Validation

Avatar

Former Community Member
I want to produce a custom error message on submit

when a checkbox value=0 (unchecked).



Detailed suggestions would be welcome.
4 Replies

Avatar

Former Community Member
This can help you.



Try to make your own custom submit button, is very simple. On click event, put the following lines:



i //Custom submit button.



> var check = xfa.resolveNode("here your check box node");



> var url_address = "the address/email where you want to send it";



//Getting the document's target object. It be used later in order

//to send the document.



> var doc = event.target;



//Validating the document. You can put here the rest of the

//document's validations.



> if(check.rawValue == 0){



> app.alert("Error, select the check box option");



>}else{



> //Submit the document. See the documentation for



> //more submit options.



> doc.submitForm( { cURL: url_address } );



>}



b Good luck,



Dan

Avatar

Former Community Member
Thank you Dan for a detailed description of the process.



Howard

Avatar

Former Community Member
Dan,



I gave it a try and we are almost there.



If the box is not checked, I get the error message. If the box is checked the script attempts to connect to the URL where the script resides followed by /emailaddress. The file is temporarily located at http://www.lewisborogov.com/dan.pdf.



Howard



This is what I have for the click - javascript, client



var check = xfa.resolveNode("CheckBox1");



var url_address = "myemail@xyz.com";



//Getting the document's target object. It be used later in order

//to send the document.



var doc = event.target;



//Validating the document. You can put here the rest of the

//document's validations.



if(check.rawValue == 0){



app.alert("You must certify that you have read Section 78.");



}else{



//Submit the document. See the documentation for



//more submit options.



doc.submitForm( { cURL: url_address } );



}

Avatar

Former Community Member
Ok try this:



> var url_address = "
mailto:myemail@xyz.com";



b Regards...



Dan