简体   繁体   English

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

[英]VarienForm not working in magento 1.9.2 community edition

Hello I am developing a login and register form in magento. 您好,我正在用magento开发登录和注册表格。 For form validation I am using this code 为了进行表单验证,我正在使用此代码

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

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

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

when i am using this code in phtml with script tag it is working but when I am putting it in js and calling through xml it is not working here is my xml code 当我在带有脚本标签的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>

To check whether js is loading or not i put alert() in it , I got the popup but I don't know why the validation code is not working. 要检查js是否正在加载,我在其中放入了alert(),我弹出了窗口,但我不知道为什么验证代码不起作用。 Any Help will be appreciable. 任何帮助将是可观的。

If you want simple validation than better you use magento in built validation class form validation 如果您想要简单的验证而不是更好的验证,可以在内置的验证类表单验证中使用magento

refer this 参考这个

Form Validation classes 表单验证类

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

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