Well, if the battery is the problem, there is no way to 'fix' it. All you can do is replace it. It, however, may not be the battery and may be the charger cord.
Try turning off the laptop and connecting the cord. Does it charge when off?
If yes, it charges when turned off, but not when turned on, then the cord is most likely your issue. When the cord is damaged (and you don't have to see the damage) it will often only put out part of the necessary power to both power the device and charge the battery.
In this case you would need to replace the cord.
Now if it won't charge no matter if the laptop is turned off or on, then it could be the battery needs replacing, or the charging circuit in the laptop is bad.