繁体   English   中英

VarienForm在magento 1.9.2社区版中不起作用

[英]VarienForm not working in magento 1.9.2 community edition

您好,我正在用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(),我弹出了窗口,但我不知道为什么验证代码不起作用。 任何帮助将是可观的。

如果您想要简单的验证而不是更好的验证,可以在内置的验证类表单验证中使用magento

参考这个

表单验证类

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM