How do you read the lat and long values.
But whenever the user did not put the location which is the lat and long will become an empty string the deliverycharges will become 0.
Where is the conversion from an empty string to zero done.
When you try to convert an empty string to a number you get an error.
So you should check valid lat and long values there.
I would also check if the distance is realistic or not, there is probably a max range of action value which could be checked.