I've had that exact problem before. Inside the valve core there is a small rubber cylinder that slides up and down. When you try to inflate, the inrush of air pushes this rubber bit down towards the closed end of the core, leaving the little holes on the sides open for air to enter the tube.
When the pump is disconnected, air tries to escape through the valve, pushing the rubber bit towards the top, where it hits and rest against an inner ledge. Air pressure from inside the tube keeps pressing this bit against such ledge, creating a seal.
This style of core is prone to getting dirt or dust specs getting inside, possibly sticking to the rubber seal, preventing it from doing its function.
What I have done is taking the core out and shoving it in a hand pump (A floor pump should work too), then give it a few hard strokes, causing a few rushes of air flowing through the valve. The hope is this ram of air removes dirt from inside the valve core, after which it works fine. Be careful not to shoot the core away. If the pump you are using does not hold it tightly, point it in such manner that you catch it in a towel, a bucket or something.
However, this inner rubber seal can also get dried up, loosing flexibility or developing cracks. In such cases it is better to exchange the core for a newer one.
So, my advice is to buy a few cores, change the faulty one and keep one or two in your patch kit or emergency tool pack, they should be very cheap if they are common in your country. In my case they are more popular with "work" bikes than in "sport" bikes, and as such, it is way easier to find Dunlop tubes or cores in some hardware stores or department stores rather than in bike shops.
Try the hand pump thing anyway. It may be enough to make the core work as intended and it cost nothing but a few minutes if you already have a hand pump or a floor pump.