0

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 .

4
Contributors
5
Replies
6
Views
6 Years
Discussion Span
Last Post by phpbeginners
0

alert and back to referrer:

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

1

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" />
Votes + Comments
THIS HELLLLLPED ME !!!
0

:)

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.