If the battery warning light (a light in the shape of a battery symbol) on the dashboard comes on while you're driving, that means the charging system isn't working, but the fault may lie in something other than the battery.
The cause of the battery light could be a loose or corroded battery cable or other wire connecting components of the charging system, or it might be a problem with the alternator or voltage regulator. The alternator generates the power that is stored in the battery. If the alternator fails, or the accessory belt that drives the alternator is loose or broken, then you'll end up with a dead battery because the bad alternator isn't recharging the battery.
The car battery itself may be the cause if it has corroded cable terminals, bad wiring, damaged cells or plates inside or if it is leaking electrolyte. This article refers primarily to conventional vehicles with conventional 12-volt batteries; more electrified vehicles and those higher-voltage electrical systems will vary.
The charging system warning light should show for a few seconds when you start the car, but if the battery light shows while you're driving the vehicle, that light signals a problem. Among other signs that the alternator or other parts of the charging system aren't working are dim headlights or the clock losing time.
If the car's dashboard battery light comes on, you might be able to make it home or to a service facility for a repair. The car will continue running as long as some juice is left in the battery, but if the charging system isn't working or you have a bad alternator, your car's engine will stop running once the battery is drained. If you turn off the engine, you won't be able to restart it if the battery doesn't have enough charge left to power the engine's starter motor.
If the battery light is on and you're still driving the car, turn off as many electrical accessories as you can, such as the stereo, air conditioning or heater, and avoid using electrical controls such as power windows.
Reducing the amount of electricity the car is consuming will increase the distance you can drive before the battery is discharged. Get to a mechanic as quickly as possible, and have the battery, wires and charging system checked out to find the cause of your problem and what you need to repair or replace.