So if it is only powering on when you have only the charger attached or only the battery in, not both, then it is probably the charger that is the problem.
One of the ways they act when they are going bad is that they will power a device, but not power it and charge the battery at the same time. So they either stop charging the battery while connected the the laptop is on, or they just won't work when the battery is in (trying to charge). Different devices react differently.
The only fix is to replace the charger.