Expand my Community achievements bar.

Validation before Submit in workspace

Avatar

Level 1
We want to validate the fields before the forms is submitted from workspace. We have a custom validation script(function defined) which will popup message displaying the incorrect fields.



Issue:

How do we stop the form from submission if validation is done through scripts?



Which event to be used?



Is there any specific value the function should return? Currently we return true or false based on validation.
3 Replies

Avatar

Former Community Member
Hi tailor,



Unfortunately I do not have a solution for your problem, but I think you might have a solution for mine. I hope you can help me out.



In your subscription I see that you have a custom validation script function which will popup a message displaying incorrect fields.

Can you tell me how you did this. I have been trying to do this, but I can't make it work. My problem is, how to find out if a field is incorrect. I know how to find mandatory fields that were not filled, but I do not know how to find filled fields that are incorrect.

I do have validation pattern messages defined but after the message my field stays filled with the wrong data.



Can you help me out.



Many thanks.

Avatar

Former Community Member
There maybe better ways to do this, but this is what I usually do:



Drag the "Process Fields" group onto your form,

it has a Submit button and a bunch of hidden fields named like "AWS_..."



there's a big piece of script behind that Submit button,

add the following in the very beginning of this big block of script:



if (myScriptingObject.ValidatedOK())

{

... [original script remain here]...

}



put your validation logic in the function "ValidatedOK()" which returns true or false.



The "Complete" button in the 'wrapper' of WorkSpace seems to know that it should execute that piece of script.



I heard you can also put your Validation logic in the "preSubmit" event or something, but I haven't tried that one.

Avatar

Former Community Member
Many thanks for your reply. It turns out to be quite useful to me.