<html>
<head>
<script type="text/javascript">
function validate_required(field,alerttxt)
{
with (field)
{
if (value==null||value=="")
  {alert(alerttxt);return false;}
else {return true}
}
}function validate_form(thisform)
{
with (thisform)
{
if (validate_required(email,"Email must be filled out!")==false)
  {
email.focus();
return false;
if (validate_required(city,"city fill it")==false)
{
city.focus();
return false;
}
}
}
}
</script>
</head><body>
<form action="9.php"
onsubmit="return validate_form(this)"method="post">
Email: <input type="text" name="email" size="30">
city: <input type="text" name="city" size="30">
<input type="submit" value="Submit"> 
</form>
</body></html>

i used this code to generate a alert box when email box not filled correctly and it correctly generating alert box for email and not for city... ops help me in generating alert box for city also

change the function like this ... it will work

function validate_form(thisform)
{
	with (thisform)
	{
		if (validate_required(email,"Email must be filled out!")==false)
		{
			email.focus();
			return false;
		}	
		else if (validate_required(city,"city fill it")==false)
			{
				city.focus();
				return false;
			}
		
	}
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.