I'm using Spring MVC and have a page in my web application where I have a mailing address field that is mandatory and a radio button with a question asking 'Is the billing address the same as the mailing address?' Neither yes or no is selected by default to force the user to select an answer to the question via validation.
I have currently implemented it so that in the controller, if the radio button value is 'Yes', I copy the value of the mailing address into the billing address.
My validation works like so: If the radio button has been set to yes then don't validate the billing address input fields, otherwise perform validation on those fields.
Is this an ok way to implement this functionality? The only other thing I could think of is to get JQuery to populate the values when the radio button is selected.
Why would you do the copying in the Java controller code versus Javascript?