0

在模板 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>
4

2 回答 2

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>
__('提交') ?>" id="form-submit"> __('maak mijn profiel aan') ?>
                </form>
于 2013-04-04T11:45:48.050 回答
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。

于 2013-04-04T08:08:53.440 回答