Saran Chamling loves the web technology, and enjoys designing, exploring and writing about it @sanwebe.com. You can find him at Twitter, Google or Facebook.
There are plenty of powerful jQuery validation plugins out there to meet your needs, but sometimes your requirement is so little that you just don’t bother including these plugins into your page, you might just create your own simple validation for your Form. So here’s a simple jQuery validation script you can include in your form page and have almost powerful validation.
If you are creating an image uploader, you can provide thumbnail preview of currently selected images in file input field. We don’t need to upload entire file to server to do that. File API is supported by all modern browsers, we just need to take advantage of this feature, it provides us with information about files and allows to access their content.
To select all text inside an element such as DIV, we can simply use JavaScript document.createRange() method to create a range, and than using range.selectNodeContents() we can set node range (start and end), after which use selection.addRange() to select the range of the element.
Today let’s create an Ajax based contact form, that will allow users to send attachments in email message. This tutorial has been updated recently and is based on my recent post here. I’ve added Ajax part to the the example here, it will send form data without refreshing the page.