(code samples are simplified to focus on problem)
Hello all,
I have a form:
<form onsubmit="return check(this);" action="sandbox_ajaxform.php" method="post">
The check(this) code will call a javascript function that initiates an ajax call to validate the form fields:
var validatedForm;
function check(form){
validatedForm = form;
new Ajax.Request('sandbox_ajaxform.php', {
parameters : Form.serialize(form),
onSuccess : successHandler
});
return false;
}
function successHandler(resp, jsonObj){
/**
* validation stuff here, based on
* resp.responseText. For now we
* will assume the form to be correctly validated
*/
validatedForm.submit();
}
However, the line “validatedForm.submit();” does not work. The form is not submitted. :hair:
I have tried to alert(validatedForm) and that is a normal object, and there are no Javascript errors (BugZilla).
Could anyone please shed a light on this? Any help would be greatly appreciated!