Normally the opening form tag has a few more definitions in it; the action, the id, the method. It looks like this:
Code:
<form id="myform" action="form_action.php" method="post">
The submit button normally uses this info to send the form data to the form_action.php script which acts upon the data sent.
You are validating the form data using javascript before it is submitted. The submit button calls the js function using onclick instead of of the input using onblur, but they both call the js valadation function and when that finishes the js submits the form data.
Remove the onblur from:
Code:
<input type="text" id="slug" onblur="validateUsername('slug')" />
Add a submit button:
Code:
<form id="myform" action="ajax.php" method="post">
Name : <input type="text" id="slug" /><div id="message"></div>
<input type="submit" value="Submit" onclick="validateUsername('slug')" />
</form>
And then when the js validates everything as good you call the submit function:
Code:
} else {
document.getElementById(fld).style.background = 'White';
document.getElementById('message').innerHTML = '';
document.getElementById("myform").submit();
}
You can find all of this on
http://www.w3schools.com/jsref/met_form_submit.asp or google something like "submit a form with js"