不能使用varien

时间:2013-04-04 07:59:20

标签: magento

在模板register.phtml中,我为一些条款和条件协议添加了一个输入类型的无线电。 这是必需的。

我没有成功使用javascript Magento的前端验证。我添加了所有类,但没有任何效果。

有人知道该怎么做吗?感谢

这里是html

<div class="field radiobox">
    <div class="input-box">
        <input type="radio" name="accept" title="<?php echo $this->__('I Agree to our Terms & Conditions') ?>" id="accept"  class="radio required-entry validate-one-required-by-name validation-passed validation-failed" >
        <label for="accept" class=required" ><?php echo $this->__('I Agree to our Terms & Conditions') ?></label>
    </div>
</div>
<script type="text/javascript">
    //<![CDATA[
        new Varien.FileElement('accept');
    //]]>
</script>

2 个答案:

答案 0 :(得分:0)

首先删除除了必需条目之外的所有类

<input type="radio" name="accept" title="<?php echo $this->__('I Agree to our Terms & Conditions') ?>" id="accept"  class="radio required-entry" >

并将其放在您的表单标记中,您不需要为此创建任何javascript,只需确保它位于表单标记下,在register.phtml文件中magento已经定义了验证javascript所以不要放置你的javascript再次。

答案 1 :(得分:0)

@Mufaddal

<div class="account-form-wrapper registerpass">
            <form action="<?php echo $this->getPostActionUrl() ?>" method="post" id="form-validate" enctype="multipart/form-data" class="ctools-use-modal-processed" novalidate="novalidate">
                <div class="fieldset">
                    <input type="hidden" name="success_url" value="<?php echo $this->getSuccessUrl() ?>" />
                    <input type="hidden" name="error_url" value="<?php echo $this->getErrorUrl() ?>" />
                </div>
<?php  echo  $this->getLayout()->createBlock('customer/widget_name')->setObject($this->getFormData())->setForceUseCustomerAttributes(true)->toHtml() ?>

                <div class="field">
                    <label for="email_address" class="required"><em>*</em>Email Address</label>
                    <div class="input-box">
                        <input type="text" name="email" id="email_address" value="<?php echo $this->escapeHtml($this->getFormData()->getEmail()) ?>" title="<?php echo $this->__('Email Address') ?>" class="input-text validate-email required-entry" placeholder="<?php echo $this->__("Email Address") ?>" />
                    </div>
                </div>

                <div class="fields">
                    <div class="field">
                        <label for="password" class="required"><em>*</em><?php echo $this->__('Password') ?></label>
                        <div class="input-box">
                            <input type="password" name="password" id="password" title="<?php echo $this->__('Password') ?>" class="input-text required-entry validate-password" placeholder="Password" />
                        </div>
                    </div>
                    <div class="field">
                        <label for="confirmation" class="required"><em>*</em><?php echo $this->__('Confirm Password') ?></label>
                        <div class="input-box">
                            <input type="password" name="confirmation" title="<?php echo $this->__('Confirm Password') ?>" id="confirmation" class="input-text required-entry validate-cpassword" placeholder="Confirm Password" />
                        </div>
                    </div>
                </div>

                <div class="field radiobox">
                    <div class="input-box">
                        <input type="radio" name="accept" title="<?php echo $this->__('I Agree to our Terms & Conditions') ?>" id="accept"  class="radio required-entry" >
                        <label for="accept" class=required" ><?php echo $this->__('I Agree to our Terms & Conditions') ?></label>
                    </div>
                </div>
                        __('提交')?&gt;“id =”form-submit“&gt;                             __('maak mijn profiel aan')?&gt;                                              
                </form>