开发者

Magento ajax form validation

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜