This is an updated and improved version of AJAX Generic Form Parser
That’s nice, but what does it do?
Before I present to you the Code Example, I’ll explain a little about how to configure your form and make certain fields required.
For simplicity, I’ve chosen to make use of the fields ‘Title’ tag. This is where you make fields required.
For example: < input type="text" name="FirstName" title=”required” >
Note: The script will support the following form field types:
Just to recap. To make any of the supported fields required, just add title=”required”!
< form name="myForm" method="post" action="process.php" onSubmit=”return myForm.check(this)” >
We must use return before the function call, this tells to form ‘do not submit the form unless the function returns true’.
As you can see, this is nice and easy to follow. Nothing to fancy, but believe me this wee function can save a lot of time, especially if you build a lot of forms.
Why does it not do more complex validation?
Simple, because I like to keep things nice and easy (and I don’t do complex)…. The last thing I want to do is give you a headache. Like everything on this site, this is just an example. Please feel free to use and enhance it to fit better with your own needs.