Javascript validation defined in vardefs is ignored

I added the following code to the $dictionary array in crm/modules/FP_events/vardefs.php. Then I ran “Quick Repair and Rebuild.” To test, I’m editing an event. But when I hit save, it just saves. The code should at least cause a "hi there’ alert popup. But nothing happens. Note that I would have edited vardefs in the custom folder, but I’m not sure how that works with editing a file that has been auto-generated with all my Studio changes.

$dictionary['FP_events']['fields']['my_cool_field_c']['validation'] = array (
'type' => 'callback',
'callback' => 'function(formname,nameIndex){alert("hi there"); if($(“#” + nameIndex).val()!=999){add_error_style(formname,nameIndex,”Only 999 is allowed!”); return false;}; return true;}'
);

Got the idea from…
https://gunnicom.wordpress.com/2015/09/21/suitecrm-sugarcrm-6-5-add-custom-javascript-field-validation/

You can get some notion of the different kinds of validations available by checking this switch:

C:\Users\Pgr\PhpstormProjects\SuiteCRM\jssource\src_files\include\javascript\sugar_3.js

You will find your callback there. And also other simpler validations which you might prefer.

First, try to use some Javascript debugging from your browser’s developer console to check if your customization got loaded into the “validate[]” array.

Another thing - about adding this directly into the vardefs (which I think is a good idea) exactly which file did you try changing? If you edit the correct file it won’t be overwritten by a QR&R.

I could not find my new js code in the sugar_3.js. Judging by the file timestamp, I don’t think that file has ever been updated. Permissions are “-rwxr-xr-x 1 www-data www-data”

exactly which file did you try changing?

mydomain/crm/modules/FP_events/vardefs.php

Note that I would have edited vardefs (somewhere?) in the custom folder, but I’m not sure how that works with editing a file that has been auto-generated with all my Studio changes.

Not sure where to go from here.

In Admin repairs, try the Javascipt rebuilds.

I was looking for my javascript in the page source code, but it looks to be added to the dom after the page loads. What’s interesting is that I’m getting an error that the jquery ($) is an illegal character. Shouldn’t jquery be recognized by this point?