
This lightweight JavaScript form validation allows you to easily add attractive validation messages to your forms. There is no markup to add on your existing page. Just call the inlineMsg() function when you wish to display a message. The position of the form element (or any other element) is dynamically calculated.
Call the function as follows.
inlineMsg('name','You must enter your name.',2);
The first parameter is the id of the element you wish to display the warning in relation to. The second is the string you wish to display in the message box. You can include HTML, just be sure and escape when necessary. The third parameter is the time to display the message in seconds. It is optional and if left empty will default to the MSGHIDE variable in the JavaScript which is initially set to 3.
This script has been tested in all major browsers and is available free of charge for both personal or commercial projects under the creative commons license. Community support is available here. Paid support is also available, contact me for details.
Click here to download the source.
Update 5/5/2008 – Updated the script to focus to the erroneous textbox when displaying an alert. Thanks to mbh for the suggestion.
Update 6/2/2008 – Resolved issue with form field focus on non textbox fields. Added select dropdown to the demo and source.

Pingback: Dynamic Inline JavaScript Form Validation
Pingback: Mensajes dinámicos javascript en tus formularios | miguelpuig.com
Pingback: WanderingBit · Just another place to wander
Pingback: Welcome Back! | Division Overlay Blog
Pingback: 16+ Top JavaScript/Ajax Effects for Modern Web Design - aComment.net
Pingback: Liens pour effets Javascripts Web 2.0 | Charlie Nguyen-Duc
Pingback: JavaScript Validation « Pixelerium
Pingback: Web Form Validation: Best Practices and Tutorials | How-To | Smashing Magazine
Pingback: Web Form Validation: Best Practices and Tutorials | Desinine
Pingback: Web Form Validation: Best Practices and Tutorials « Ramesh
Pingback: Web Form Validation: Best Practices and Tutorials | Results videos photos news blogs At I google wiki . com
Pingback: Web Form Validation: Best Practices and Tutorials — missrix
Pingback: Fun with JavaScript: Form Validation « inspiration
Pingback: Six Digit Media | Web Form Validation: Best Practices and Tutorials | Cincinnati's Premier Web Design and Development Company - We are the Bottom Line in Online Marketing
Pingback: 16+ Top JavaScript/Ajax Effects for Modern Web Design | DevWebPro
Pingback: Web Form Validation: Best Practices and Tutorials | WebsGeek
Pingback: Geek is a Lift-Style. » Web Form Validation: Best Practices and Tutorials
Pingback: Formularvalidierung in Echtzeit für zufrieden User | grafixx.at