By: Prem Tiwari | Last Updated:
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:
if (x==null || x=="")
alert("Please enter the name.");
<form name="contact" action="demo.php" onsubmit="return validateForm()"
First name: <input type="text" id="name" name="name">
<input type="submit" name="submit" value="Submit">
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 and also he has been a regular speaker of WordPress sessions in various IT Companies.View all posts by Prem Tiwari