Disable the field B when field A is filled

Hi everyone ;
I have One Module that contain 2 fields:

  • Rate
  • Amount

My need :
I have to fill ONE of the fields, not both at once.
- The rate OR - Amount like that

How can i proceed to solve this issue,
Im waiting ur suggestions, and thank u for ur help

Hi dpccrt87,

This would require custom javascript to be added to the page which would disable one of the fields when the other has content.

Ian.

Thank u for ur reply Mr LAN ;
But if possible , can u explain me more, how can i proceed ?

Hi dpccrt87,

To get you started you could have a look at this blog post. it shows you how to add javascript to a editview page.

http://developer.sugarcrm.com/2013/09/06/adding-javascript-files-to-edit-and-detail-views/

from here its just using traditional javascript to add the logic to disable the field when the user interacts with the other.

Ian.

Thank u very much :wink:

Its done

$(document).ready(function(){
$("#rem_taux_c").focus();
$("#rem_taux_c").keyup(function() {
if($("#rem_taux_c").val().trim() == “”){
$(’#rem_forfait_c_label’).show();
$(’#rem_forfait_c’).show();

    }
    else{
	    $('#rem_forfait_c_label').hide();
                $('#rem_forfait_c').hide(); 
		
    }
});

$("#rem_forfait_c").focus();
$("#rem_forfait_c").keyup(function() {
    if($("#rem_forfait_c").val().trim() == ""){
        $('#rem_taux_c_label').show();
		$('#rem_taux_c').show();
		
    }
    else{
	    $('#rem_taux_c_label').hide();
                $('#rem_taux_c').hide();		
    }
});

});