A Variational Principle for Problems with Functional Constraints