I want cancel change event when selected item compare with another select list value. I have 2 selectlist.I want when #SecondUnit_Id changed execute below function but does not work.
var preval=$('#SecondUnit_Id').val();
$('#SecondUnit_Id').change(function(){
  
  if($(this).val()==$('#UnitList_Id').val())
    {
       msgbox("error","Duplicate");
       $(this).val(preval);
       return false;
    
    }
    
    preval=$(this).val();
  
  });But Does Not Work below code:
$(this).val(preval) 
    