Conditional required field

QuestionsConditional required field
Stephen Hartigan asked 10 years ago

Hi,

I have a notes field which is only required if my Status field = 'Reject' is it possible to set a field to required based on the value in another field?

Thanks for your help.

7 Answers
Stephen Hartigan answered 10 years ago

Please ignore the above I have figured it out from the example: js-validation-form

Thank-You

Abu Ghufran answered 10 years ago

Please check this code and recheck.

http://pastebin.com/VZbSda53

kim answered 10 years ago

could you please give example of this?
i tried using the js-validation-form example but still stuck.
any help would be greatly appreciated
thank you.

2 fields contract_Worth and contract_ApprovedDate

condition would be placed within this field:
$col = array();
$col["title"] = "APPROVED";
$col["name"] = "contract_ApprovedDate";
$col["editable"] = true;
$col["editrules"] = array("required" => false, "date"=>true);
$col["condition"] = array('$row["contract_Worth"] > 10', "required" => true, "required" => false);
$cols[] = $col;

kim answered 10 years ago

cannot access this site.
any other source to solve my dilema?

Abu Ghufran answered 10 years ago

$grid["edit_options"]["beforeSubmit"] = "function(post,form){ return validate_form_once(post,form); }";
$grid["add_options"]["beforeSubmit"] = "function(post,form){ return validate_form_once(post,form); }";
$g->set_options($grid);

And in HTML script tag:

function validate_form_once(post,form)
{
var str=[];

if (post.contract_Worth > 10)
str[str.length] = "- Contract Approve Date is required";

str = str.join("<br>");

if (str.length == 0)
return [true,""];
else
return [false,"Check following errors:<br>"+str];
}

kim answered 10 years ago

error message box appearce fine, but CANNOT SUBMIT after entering value into APPROVE field?

added above code AND
$col = array();
$col["title"] = "APPROVED";
$col["name"] = "contract_ApprovedDate";
$col["editable"] = true;
$col["editrules"] = array("required" => false, "date"=>true);
$col["condition"] = array('$row["contract_Worth"] > 10', "required" => true, "required" => false);
$cols[] = $col;

$col = array();
$col["title"] = "APPROVED";
$col["name"] = "contract_ApprovedDate";
$col["editable"] = true;
//$col["editrules"] = array("required" => false, "date"=>true);
//$col["condition"] = array('$row["contract_Worth"] > 10', "required" => true, "required" => false);
$cols[] = $col;

also tried commenting out editrules and condition
NOT WORKING.
please help!!!!!

Abu Ghufran answered 10 years ago

I guess there is some misunderstanding.
Please email me full code for review and explain what exactly you want to achieve.

Your Answer

19 + 14 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?