If you are using the value of a session variable to determine if shipping is needed or not then you can do this server side with an if statement and your session variable like this:
if($_SESSION['your shippable session var'] != 1){
// the shipping portion of the form goes here
}
With this in place you can do this all with server validations. On the confirm page that this is posting to you will want to ensure that you have the validations for the various fields. You can add a similar if statement around the specific validations for the shipping fields. This way if shipping info is not required the form will not request it and the validations will not run against those elements.
If you omit the shipping values then you may want to use this same logic for the display on the confirm and checkout success pages.