I have created custom module using code and i need to have default validation (Red Mark) to EditView.
I added:
This is not working can someone guide me for validation part.
I have created custom module using code and i need to have default validation (Red Mark) to EditView.
I added:
This is not working can someone guide me for validation part.
You can add custom validation to a field just by vardefs. Add following to your field definition and adapt javascript to your needs:
'validation' =>
array (
'type' => 'callback',
'callback' => 'function(formname,nameIndex){if($("form#" + formname + " #" + nameIndex).val()!=999){add_error_style(formname,nameIndex,"Only 999 is allowed!"); return false;}; return true;}',
),
This is interesting however for people who are not so much familiar can you explain better:
-> where ti put the codes
-> which files should be copied intoa custom directory
->whch files to edit
Thank you
Thanks that working , but can you please confirm if i need to check condition for 2 or 3 fields in same thing like
e.g
$dictionary[‘Opportunity’][‘fields’][‘other_field’][‘validation’] = array(‘type’ => ‘callback’,’callback’ => ‘function(formname,nameIndex){if($(“#” + nameIndex).val() + $(“#other_field1”).val() + $(“#other_field2″).val() != 100){add_error_style(formname,nameIndex,”Total must be equal to 100”); return false;}; return true;}’,);
how to make it work?
This looks good to me. Maybe there is a problem with the decimal delimiter (",",".").
edit
Andy maybe additional brackets like:
(($(“#” + nameIndex).val() + $(“#other_field1”).val() + $(“#other_field2″).val()) != 100)
I note that the delimiters are weird on the code posted above, maybe it’s just here in the forums?
` and ´ instead of ’
You can use the forum’s code tags to make sure things display exactly as entered.