Form validation using the javascript

| Last Updated: | In: HTML / CSS, Javascript & Ajax


In today’s post i will explain to how to validate a form using javasrcipt. This is very easy & simple javasrcipt code to validate text box. JavaScript can be used to validate data in HTML forms before sending the data to web server.

Below function check if form text box is blank .If the text box is left blank, an alerts message is display as popup on the web pages, and  function returns false, and the form will not be submitted:

Javascript Code

HTML Code

Add below HTML code after body tag. In the below i have added a javascript function validateForm() and define the same function in above javascript code which will get the text box value and validate according to define rules.

 

Tags: , , , , , ,


About: Prem Tiwari

Prem Tiwari is the founder of freewebmentor.com and is a professional developer who has vast experience in PHP and open source technologies. Apart from this, he is a blogger by hobby.


You may also like:

Get Free Access of 450+ Scripts

Don't worry you'll not be spammed!

Featured eBook

WordPress Security Guide

Free Guide: Learn how to implement security guideline in your WordPress site...

DOWNLOAD

Free WordPress Setup Service

Free WordPress Setup

Want to Setup WordPress Blog Setup? I will help you in the setup of your WordPress blog.

Click Here

Pincode Finder

pincode-finder tool

Online Pincode Finder

Best tool to locate post Office address and pincodes of all india...

SEARCH NOW