# help creating a really simple ajax form verification



## Easy Rhino (Apr 5, 2010)

i am tooling around with ajax but seem to be lost. i created a real simple form and want to use ajax to check that the form is completely filled out when the submit button is pressed. here is my code...


```
<?xml version = "1.0" encoding = "utf-8"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3c.org/TR/xhtml1/DTD/xhtml1-strict.dtd">


<html xmlns = "http://www.w3c.org/1999/xhtml">


<head>
<title>AJAX</title>

<script type="text/javascript" language="JavaScript">
<!--
	var asyncRequest;

	function getContent(url)
	{
		try
		{
			asyncRequest = new XMLHttpRequest();

			asyncRequest.onreadystatechange = stateChange;
			asyncRequest.open('GET' , url, true);
			asyncRequest.send(null);
		}

		catch (exception)
		{
			alert('Request failed.');
		}
	}//end function getContent

	function stateChange()
	{
		if (asyncRequest.readyState == 4 && asyncRequest.status == 200)
		{
			document.getElementById('contentArea').innerHTML = asyncRequest.responseText;
		}
	}//end function stateChange
</script> 
	
</head>

<body>
<h2>Feedback Form</h2>
	
<form method = "post" action = "" name = "feedback">
	
		<label>Name:</label><br>
		
			<input name = "name" type = "text" size = "25" maxlength = "30" />
<p>
		<label>Street Address:</label><br>
		
			<input name = "streetnumber" type = "text" size = "25" maxlength = "30" />
<p>
		<label>City:</label><br>
		
			<input name = "cityname" type = "text" size = "25" maxlength = "30"/>
<p>
		<label>Zipcode:</label><br>
		
			<input name = "zipcode" type = "text" size = "12" maxlength = "12" />
<p>
		<label>Email Address:</label><br>
		
			<input name = "email" type = "text" size = "25" maxlength = "30" />
<p>
		
	
	<input type = "submit" value = "Submit" />
	   <input type = "reset" value = "Clear" />
</form>

</body>

</html>
```


----------

