I am trying to only allow a click event to fire if a function return is true. I am not sure if this is the correct syntax or not. Any help would be awesome.
onclick="if(AveryValidateAddress())Shipping.save()"
The way you have it written, you could accomplish this by taking advantage of the && operator's lazy evaluation. If the first part of your and statement evaluates to false, it won't attempt to evaluate the second part.
onclick="AveryValidateAddress() && Shipping.save()"
However, since you're using jQuery, a better approach would be to take advantage of jQuery's event binding:
<a href="#" id="saveButton">Click to save</a>
<script>
$(document).ready(function(){
$('#saveButton').click(function(){
if( AveryValidateAddress() ){
Shipping.save();
}
});
});
</script>
onclickhandler, write a separate save function and add it viaaddEventListener.addEventListeneris not supported by some/all versions of Internet Explorer.