Showing results for 
Search instead for 
Did you mean: 

One Step Checkout Age Validation Field

One Step Checkout Age Validation Field

Hi guys,


How can I add the age validation field in one step checkout module? Is there an easy way?






Re: One Step Checkout Age Validation Field

 It use dob.phtml widget.


Find customer/widget/dob.phtml and add it to your template from Base


Just add the following JS to the <script> tags


Varien.DOB.prototype.initialize = Varien.DOB.prototype.initialize.wrap(
    function(original, selector, required, format) {
        var el = $$(selector)[0];
        var container       = {};       =, '.dob-day input')[0];
        container.month     =, '.dob-month input')[0];
        container.year      =, '.dob-year input')[0];
        container.full      =, '.dob-full input')[0];
        container.advice    =, '.validation-advice')[0];
        //we need this to make the object avaliable and enable wrapping of  validation method
        this.dateElement = new Varien.DateElement('container', container, required, format);
Varien.DateElement.prototype.validate = Varien.DateElement.prototype.validate.wrap(
            var today = new Date();
            if (today >= new Date(this.fullDate.getFullYear() + 18, this.fullDate.getMonth(), this.fullDate.getDate())) {
                return true;
            } else {
                this.advice.innerHTML = this.errorTextModifier(Translator.translate('You have to be at least 18 years old.'));
                return false;