2016-04-18 54 views
0

你好,我正在开发一个登录和登记表格在magento。对于表单验证我使用这个代码VarienForm不工作在magento 1.9.2社区版

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是加载与否,我把警报()中,我得到了弹出,但我不知道为什么验证码无法正常工作。任何帮助将是可观的。

回答

0

如果你想简单的验证比你使用内置的验证类表单验证的Magento

请参阅本

Form Validation classes