Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Custom Field Validation

Avatar

Level 2

Hello there

Is it possible to use a Javascript function to validate a field, rather than use the “Validation Pattern” approach?  I am OK to write the function, however I also want to be able to use it with the Form Level Validation Settings (having the function run again when the form submits etc.).

I have seen references to the “Run custom validation script” option on a Validate tab, however I don’t see these.

I am using LiveCycle Designer 9. 

Many thanks

Geoff Olding

5 Replies

Avatar

Former Community Member

Yes you can use your own code on the Validate event …simply return a true or false value and the script error message will fire appropriately

Paul

Avatar

Level 2

Thanks for the reply, however this doesn't work.

I am returning true (or false) from the Validate event, and have set the Validation Script Message appropriately.

After entering a value in the field, nothing happens.

Regards

Geoff Olding

Avatar

Former Community Member

Tried it here and it worked fine. Here is my code on the Validate event of the field I wanted to test:

if (this.rawValue == "1111"){

true

} else {

false

}

If the user enters 1111 in the field then true is rturned and nothing will happen and the tab will put thecursor in the next field. If they eneter anything else then false is returned and the Validate script error message is displayed.

Paul

Avatar

Level 2

I now have this working.

You can use the following line of code in the validate event:

event.rc = false

Thanks for your help (I assumed you meant that the function should return true or false).

Thanks for your help.

Avatar

Level 2

Hello again

It would probably be sensible to document this properly in the LiveCycle documentation.