Javascript Form Validation:-
Here is the sample source code of the above demo
Code:
<html>
<head>
<title>Javascript Form Validation</title>
<script language='JavaScript' type='text/JavaScript'>
<!--
function validate() {
	if(document.form1.textinput.value=='')
		{
		alert('Fill the Input box before submitting');
		return false;
		}
	
	else	{
		return true;
			}
}
//-->
</script>
</head>
<body>
<form name='form1' action='javascript_validation.php' method='post' 
				onSubmit='return validate();'>
Input :<input type=text name=textinput value=''>
<input type=submit value=submit>
</form>
</body>
</html>
PHP Form Validation:-In the PHP form creation page, the following line was used to start the form.
Code:
<form name="addLink" onSubmit="return checkForm(this);" action="addurl.php" method="POST">
This line invokes a JavaScript routine which is contained in the HTML header part of the page. If this routine returns with a successful status, the action item is called which means that "addurl.php" is called and data from the form is passed to it. Sessions are not required to pass this data to the addurl.php file and the names of values created on the form page will be available. These values include:
* title
* description
* uname
* email
* stype
* category
This JavaScript function will check to be sure there is a URL, title, link description, and category entered.

Code:
<SCRIPT LANGUAGE="JavaScript">
<!--
function checkForm(TheForm) {
  // url, title, description
  if (TheForm.url.value.length == 0) {
   TheForm.url.value = prompt("You forgot to enter the link URL for addition!");
   return false;
  }
  if (TheForm.title.value.length == 0) {
   TheForm.title.value = prompt("You forgot to enter the link title for addition!");
   return false;
  }
  if (TheForm.description.value.length == 0) {
   TheForm.description.value = prompt("You forgot to enter the link description for addition!");
   return false;
  }
  if (TheForm.category.value.length == 0) {
   TheForm.category.value = alert("You forgot to enter the category!");
   return false;
  }
  return true;
}// end function checkalForm
// -->
</SCRIPT>