# Prototype + AJAX form validation trouble

**URL:** <https://forum.kirupa.com/t/prototype-ajax-form-validation-trouble/201334>\
**Category:** Uncategorized\
**Created:** [September 20, 2006, 3:30pm UTC](https://forum.kirupa.com/t/prototype-ajax-form-validation-trouble/201334 "2006-09-20T15:30:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![maurits](https://avatars.discourse-cdn.com/v4/letter/m/dec6dc/32.png) [@maurits](https://forum.kirupa.com/u/maurits)\
**Post date:** [September 20, 2006, 3:30pm UTC](https://forum.kirupa.com/t/prototype-ajax-form-validation-trouble/201334/1 "2006-09-20T15:30:39Z")

</div>

_(code samples are simplified to focus on problem)_

Hello all,

I have a form:

```auto
<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:

```auto

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!
