Obedience is required, but that is not what "earns" you salvation. Faith in Jesus is what saves you, in that you believe in his teachings to the point of obedience, to the best of you ability, to do what you believe is right, though you may fall short sometimes.