2

I am fairly new to using SugarCRM and I am just trying to do some validation on a form page I have.

I am simply trying to get the value of my dropdown, and perform my error if it is equal to "None" but I am unsure how to get the value using SugarJS.

Here is an example of how i get just a basic input field, which is working correctly.

var first_name = $('input[name=first_name]').val();
var last_name = $('input[name=last_name]').val();

if (first_name == "") {
    $('input[name=first_name]').css({'border':'2px solid red'});
    proceed = false;
}

if (last_name == "") {
    $('input[name=last_name]').css({'border':'2px solid red'});
    proceed = false;
}
Sumner Evans
  • 8,951
  • 5
  • 30
  • 47
user2168066
  • 627
  • 11
  • 21
  • SugarCRM has some built in validation you can add to the form element in the control panel. You can flag the validator to take action when specific value `None` is reached. – Adam T May 06 '15 at 19:23
  • Sorry, but the level of validation you get depends on the version in use (professional, etc.) http://stackoverflow.com/questions/19184018/field-validations-in-sugarcrm – Adam T May 06 '15 at 19:25

1 Answers1

0

See how I make: https://github.com/ErasmoOliveira87/SugarCRM

I create one logic hook to load js files, and use a normal Jquery inside of scripts.js file (I never found other way to do this). This solution I use to professional versions, and works for community too. If you have access to FTP to manipulate the files you just need create the structure otherwise if you using professional version you need to create one package with manifest file(have example in git too).

fields with "_c" are custom fields, you can see the names in studio.

$(document).ready(function(){

    $('#account_name').val("Some value");
    $('#phone_number').val("Some value");
    $('#YOUR_CUSTOM_FIELD_ID_c').val("Some value");
    $('#YOUR_CUSTOM_FIELD_ID_c').val("Some value");

});

After create everything you need go to Admin > Repair > rebuild to clean all cache files.

ErasmoOliveira
  • 1,416
  • 2
  • 20
  • 40