【问题标题】:VarienForm not working in magento 1.9.2 community editionVarienForm 在 magento 1.9.2 社区版中不起作用
【发布时间】:2016-04-18 09:52:59
【问题描述】:

您好,我正在使用 magento 开发登录和注册表单。对于表单验证,我正在使用此代码

var registerForm = new VarienForm('register-form', true);

var loginForm = new VarienForm('login-form', true);

if (this.validator && this.validator.validate()) {
    this.form.submit();
}

当我在带有脚本标记的 phtml 中使用此代码时,它正在工作,但是当我将它放入 js 并通过 xml 调用时,它不起作用这里是我的 xml 代码

<custom_abc_index>

    <reference name="root">
        <action method="setTemplate">
            <template>page/1column.phtml</template>
        </action>
    </reference>

   <reference name="head">
        <action method="addItem">
            <type>skin_js</type>
            <name>js/custom_abc/customLoginRegister.js</name>
        </action>
    </reference>

    <reference name="content">
        <block type="custom_abc/custom" name="custom" template="custom_abc/Custom.phtml"></block>
    </reference>


</custom_abc_index>

要检查 js 是否正在加载,我将 alert() 放入其中,我得到了弹出窗口,但我不知道为什么验证代码不起作用。任何帮助都会很重要。

【问题讨论】:

    标签: javascript php jquery magento magento-1.9


    【解决方案1】:

    如果您想要简单的验证而不是更好地使用 magento 内置验证类表单验证

    参考这个

    Form Validation classes

    【讨论】:

      猜你喜欢
      • 2016-12-08
      • 2014-06-07
      • 2015-09-26
      • 2020-09-18
      • 1970-01-01
      • 2016-08-01
      • 1970-01-01
      • 2016-10-31
      • 1970-01-01
      相关资源
      最近更新 更多