Jump to content

Make a form required


Shadeplay23

Recommended Posts

Guest FirefoxRocks

I think you do that with JavaScript. You can verify if the field has an acceptable answer, then show a message or alert box or do something if it doesn't.

Link to comment
Share on other sites

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">	<head>		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />		<title>Untitled Document</title>		<script type="text/javascript" language="javascript">			function check() {				var elem = document.getElementById('c1');				if(elem.value == 123) {					alert('Right answer');				} else {					alert('Wrong answer');				}			}		</script>	</head>	<body>		<input type="text" id="c1" value="123" />		<input type="submit" onclick="check();" />	</body></html>

Look at this. This is not a secure way to do this kind of check. Use AJAX or only PHP but in this case the page should be reloaded automatically.

Link to comment
Share on other sites

Yeah the most secure way to make form fields required is with a server-side language such as PHP, ASP, ColdFusion... since a user cannot override these pages when properly coded.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...