How to validate Required fields before onclick="review.save();"
Is there any javascript to validate required fields before this action onclick="review.save();
?
Here is my button code
<button type="submit" title="<?php echo $this->__('Place Order') ?>" class="button btn-checkout" onclick="review.save();"><span><span><?php echo $this->__('Place Order') ?></span></span></button>
This is the selection box code: (I tried both required & required-entry)
<label class="commentlabel required-entry required" for="ordercomment-comment">
<?php echo $survey_question; ?> <em>*</em></label>
<div class="input-box required-entry">
<select class="validate-select required-entry" id="socialtype" name="socialtype1" title="<?php echo $survey_question ?>">
<option value=""><?php echo $this->__("- Select -");?></option>
<option value="Friend/Relative/Acquaintance"><?php echo $this->__("Friend/Relative/Acquaintance");?></option>
<option value="Google search"><?php echo $this->__("Google search");?></option>
<option value="Gumtree Advert"><?php echo $this->__("Gumtree Advert");?></option>
<option value="Facebook"><?php echo $this->__("Facebook");?></option>
<option value="Other"><?php echo $this->__("Other");?></option>
</select>
this is opcheckout.js
var Review = Class.create();
Review.prototype = {
initialize: function(saveUrl, successUrl, agreementsForm){
this.saveUrl = saveUrl;
this.successUrl = successUrl;
this.agreementsForm = agreementsForm;
this.onSave = this.nextStep.bindAsEventListener(this);
this.onComplete = this.resetLoadWaiting.bindAsEventListener(this);
},
save: function(){
if (checkout.loadWaiting!=false) return;
checkout.setLoadWaiting('review');
var params = Form.serialize(payment.form);
if (this.agreementsForm) {
params += '&'+Form.serialize(this.agreementsForm);
}
params.save = true;
var request = new Ajax.Request(
this.saveUrl,
{
method:'post',
parameters:params,
onComplete: this.onComplete,
onSuccess: this.onSave,
onFailure: checkout.ajaxFailure.bind(checkout)
}
);
},
resetLoadWaiting: function(transport){
checkout.setLoadWaiting(false, this.isSuccess);
},