Validating form with jquery(ajax), problem with captchas

Well i am a bit stuck on using the jquery, ajax and zend framework combined. I found good tutorial from http://www.zendcasts.com/ajaxify-your-zend_form-validation-with-jquery/2010/04/, i made some tests and got all working, the problem is the captcha value changes with every post request(also csrf token), how to check the validation on data forms not …

via PHP Website Development » Search Results » ajax:

Validating form with jquery(ajax), problem with captchas

Well i am a bit stuck on using the jquery, ajax and zend framework combined. I found good tutorial from http://www.zendcasts.com/ajaxify-your-zend_form-validation-with-jquery/2010/04/, i made some tests and got all working, the problem is the captcha value changes with every post request(also csrf token), how to check the validation on data forms not on captcha fields ?
Currently i have thought to use the method isValidPartial() and redesign the form.
……………………………………..

I’ve looked into that tutorial. File index.phtml, the validating section of code
function doValidation(id)

var url = ‘/index/validateform’
var data = ;
$(“input”).each(function()

data[$(this).attr(‘name’)] = $(this).val();
);
$.post(url,data,function(resp)

$(“#”+id).parent().find(‘.errors’).remove();
$(“#”+id).parent().append(getErrorHtml(resp[id], id));
,’json’);
}You see, the line
$(“input”).each(function() … )is walking over form inputs to grab the data from them (and send it for validation then). The selector is “input”, you need to rewrite it so that it wouldn’t match a captcha element. I don’t know what html is rendered for the form in your application, but considering that form inputs usually have an “id” attribute, you can change the selector to “input[id!=captcha_input_id]“, where ‘captcha_input_id’ is the id of the input to skip.

For more info: Validating form with jquery(ajax), problem with captchas

PHP Website Development » Search Results » ajax

Validating form with jquery(ajax), problem with captchas

Share this post:

Related Posts

Leave a Comment