This seems like a really silly thing to have to ask but how can I make SmartForm fields conditionally required? I found this but I'm hoping there's a better way by now? http://codingfromzero.blogspot.ca/2014/01/conditional-validation-in-k2-smartform.html
Dear ,
there are 2 approaches ,
first is the codition "If form passes validation", in this way u can validate any visible control on the form , so if u hide/show controls it will handle it and only validate visible ones ,
second apporach is to use "Advanced condition" , and specify on the conditions u got ,
if (Condition 1 & control 1 & control 2)
if(Condition 2 & control 3 and control 4)
Note : Or u could use both of these rules together to make a conditional validation ,
if condition 1 && form passes validation --> specifiy which fields to validate when its condition 1 ,
if condition 2 && form passes validation --> specify which fields to validate when its condition 2.
Hope it helps!
Regards.
Hi Ahmad, thanks for your response.
I get what you mean about using advanced conditions but what I don't understand is what action to take then.
Let's say Field2 is only required if Field1 is not empty. So my form has a submit button, and I'm putting an advanced condition when the button is clicked, yeah? My condition would be "If Field1 is not blank & Field2 is blank". But then what? Do I display a message to the user and stop the rest of the submit rules from running with "Stop rule execution"?
For this exact scenario , yes wt u r sayin is possible , and yes displaying a msg and stop the submit from executing is the right approach to go for .
Wt wt i would do is , add data label and give it convinient name maybe FormValidation and value 1 , and on my submit button first condition is if (field 1 isnt empty and field 2 is empty) transfer 0 value to the data label .
After this condition u could use this data field value in any condition u check if these fields r validated or not .
Note: or u could do the data label approach with an expression , just to have more control like having if conditions inside the expression , if field 1 is empty return 1 or if field 1 isnt empty and firld 2 isnt empty return 1 or if field 1 isnt empty and field 2 is empty return 0 , and then use this value as discussed previously .
Hope it helps ,
Regards.
Reply
Enter your username or e-mail address. We'll send you an e-mail with instructions to reset your password.