i have created a web page and placed some text boxes on it, now i'm looking to create an error massages when a person enter a wrong input the error massage will tell him/her to enter the right one and also if he/she left a text field empty and clicked a button, an error msj will inform the user that there's an empty field .

alert and back to referrer:

echo "<script>alert(\"Username not found.\")</script>"; die("<script type=\"text/javascript\">window.history.back();</script>");

Check this code.
And implement as per your need.

<script language="javascript">
function valid(form)
{
	if(form.name.value=="")
	{
		alert('Please enter name');
		return false;
	}
	else if(form.subject.value=="")
	{
		alert('Please enter subject');
		return false;
	}
	else
	{
		return true;
	}	
}
</script>
<form name="frm" id="frm" method="post" onsubmit="return valid(this);">
<br />Name : <input name="name" type="text" />
<br />Subject : <input name="subject" type="text" />
<br /><input name="send" value="Send" type="submit" />
commented: THIS HELLLLLPED ME !!! +0

vibhadevit

you can still turn on and off on javascript

:)

Check this code.
And implement as per your need.

<script language="javascript">
function valid(form)
{
	if(form.name.value=="")
	{
		alert('Please enter name');
		return false;
	}
	else if(form.subject.value=="")
	{
		alert('Please enter subject');
		return false;
	}
	else
	{
		return true;
	}	
}
</script>
<form name="frm" id="frm" method="post" onsubmit="return valid(this);">
<br />Name : <input name="name" type="text" />
<br />Subject : <input name="subject" type="text" />
<br /><input name="send" value="Send" type="submit" />

thankss a lot , it works now :):) , have a great time