Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.

Validation Loops

Avatar

Former Community Member
Hello,



I am using the following script to ensure that mandatory fields are completed before the user tabs to the next field;



*exit

if ($.rawValue == null) then

$host.messageBox("Please enter the name of the requestor","Message")

$host.setFocus ("requestor_name")

endif



This works but unfortunately it creates a loop because the next field needs to be vaildated and so on!
2 Replies

Avatar

Former Community Member
I'm trying to set up validation for mandatory fields in Adobe Designer 7.0.



Moved to a different solution but it still falls over!



The validation now takes place once the user clicks on Submit. It checks to see whether there is a value and returns an error message if a mandatory field has not been completed.



It works but after entering a value in the blank field and then clicking on submit it returns an error message.



----- form1.#subform[0].submit::click - (FormCalc, client) -----------------------------------------



var mess

var sf

if (all_ok <> 1) then

if ( requestor_details.requestor_name.rawValue == null ) then

mess = "Please enter the name of the requestor"

sf = "requestor_details.requestor_name"

all_ok = 1

endif

endif



if (all_ok <> 1) then

if ( requestor_details.directorate.rawValue == null ) then

mess = "Please enter the name of the directorate e.g. IWS, UKTI SG etc"

sf = "requestor_details.directorate"

all_ok = 1

endif

endif

if (all_ok <> 1) then

if ( requestor_details.tel_number.rawValue == null ) then

mess = "Please enter your telephone number"

sf = "requestor_details.tel_number"

all_ok = 1

endif

endif

if (all_ok <> 1) then

if ( requestor_details.organisation.rawValue == null ) then

mess = "Please choose the relevant organisation name from the drop down list"

sf = "requestor_details.organisation"

all_ok = 1

endif

endif



if (all_ok <> 1) then

// submitHidden.execEvent("click")

$host.messageBox("Form complete")

else

$host.messageBox(mess,"Message")

$host.setFocus(sf)

endif

Avatar

Former Community Member
Hello Behemut,



did you fix your problem? If so, could you paste the right code, please?