cancel
Showing results for 
Search instead for 
Did you mean: 

How to Validate Drop down menu options while submit

   Did you know you can see the translated content as per your choice?

Translation is in progress. Please check again after few minutes.

How to Validate Drop down menu options while submit

I have added a "how did u reach us" drop down in my onepage checkout.

When I press the Place Order without select any option in the Drop Down I must get the error message "There is a required field".

But now the REQUIRED options are not working as required.

Customers can place order even if there is no selection in the drop down.

I think, When pressing Place Order button it's not checking for the required fields or it's considering the blank options as a value.

This is the code.

<form value="" class="where-did-you-hear" id="checkout-agreements" onsubmit="return false;">
    <?php if($survey_question_Status && isset($survey_question_Status)) { ?>
    <div class="buttons-set">
    <ul class="form-list">
        <li>
        <fieldset>
            <ul>
            <li>
                <label class="commentlabel required" for="ordercomment-comment">
                <?php echo $survey_question; ?> <em>*</em></label>
                <div class="input-box">
<select class="validate-select" id="socialtype" name="socialtype" 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>


                </div>
            </li>

            </ul>
        </fieldset>
        </li>
    </ul>
    </div>
    <?php } ?>
    <?php if ($this->getAgreements()): ?>
    <ol class="checkout-agreements">
        <?php foreach ($this->getAgreements() as $_a): ?>
        <li>
        <div class="agreement-content"<?php echo ($_a->getContentHeight() ? ' style="height:' . $_a->getContentHeight() . '"' : '')?>>
            <?php if ($_a->getIsHtml()):?>
            <?php echo $_a->getContent() ?>
            <?php else:?>
            <?php echo nl2br($this->htmlEscape($_a->getContent())) ?>
            <?php endif; ?>
        </div>
        <p class="agree">
            <input type="checkbox" id="agreement-<?php echo $_a->getId()?>" name="agreement[<?php echo $_a->getId()?>]" value="1" title="<?php echo $this->htmlEscape($_a->getCheckboxText()) ?>" class="checkbox" /><label for="agreement-<?php echo $_a->getId()?>"><?php echo $_a->getIsHtml() ? $_a->getCheckboxText() : $this->htmlEscape($_a->getCheckboxText()) ?></label>
        </p>
        </li>
        <?php endforeach ?>
    </ol>
    <?php endif; ?>
</form>

I think the "Place Order" button rule is making the issue.

Plz have a look at the onepage/review/button.phtml

<p class="required"><?php echo $this->__('* Required Fields') ?></p>
<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>