开发者

Magento ajax form validation

开发者 https://www.devze.com 2023-04-11 10:54 出处:网络
I have a form in Magento that I build in code, and that works with ajax, which I need to validate. I would like to be able to use Magento\'s built-in validation functionality, but I don\'t know how I

I have a form in Magento that I build in code, and that works with ajax, which I need to validate.

I would like to be able to use Magento's built-in validation functionality, but I don't know how I would trigger it since the form is not submitted. The data is retrieved via ajax and outputted in a list below the form.

Is there someone who can point me in the right direction?

Thanks in advance.

Edit:

This is the javascript code used to hande the ajax request. Its called by the onclick event of the button.

function advancedtranslateSearch(url){  
    new Ajax.Request(url, {
      method: 'get',
      parameters: $('search_form').serialize(),
      onSuccess: function(transport) {
          json = transport.responseText.evalJSON();
          $('result').update('<div class="开发者_JS百科hor-scroll">'+json.records+'</div>');
      }
    });
}


You should use form's onsubmit event. To prevent page from reloading you must return false value from your function.

0

精彩评论

暂无评论...
验证码 换一张
取 消