<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>Form Validate With No Alert</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="author" content="Roderick Divilbiss">
<meta name="copyright" content="© 2005, 2006 Roderick Divilbiss">
<script type="text/javascript">
<!--
function validate(frm) {
var message='';
var fvalid=true;
if (frm.textbox1.value=='') {
fvalid=false;
message+='Please enter a value in Field 1<br>';
}
if (frm.textbox2.value=='') {
fvalid=false;
message+='Please enter a value in Field 2<br>';
}
if (fvalid==true) {
return true;
} else {
document.getElementById('errorMessage').innerHTML=message;
document.getElementById('errorMessage').style.color='#FF0000';
return false;
}
}
//-->
</script>
</head>
<body>
<span id="errorMessage">Complete the form.</span>
<form name="frmEntry" method="post" action="formValidateNoAlert.asp" onsubmit="return validate(this);">
<p>Field 1: <input type="text" size="25" name="textbox1"><br>
Field 2: <input type="text" size="25" name="textbox2"><br>
<input type="submit" value="Submit">
</form>
</body>
</html>
© Coyright 2000-2008, Roderick (Rod) W. Divilbiss. Some rights reserved.
Except where otherwise noted, this site, all content, and all source code and markup is licensed under a Creative Commons License
Creative Commons License.
No part of this web site including all application code and examples may be used for commercial purposes without prior written permission from the author,
Roderick W. Divilbiss of Overland Park, Kansas, United States of America.