The following code contains HTML and JavaScript that implements one simple way of doing this. You should be able to save the following code as an HTML file in your file system to test it. You could put the JavaScript functions in the JSHeader event of your form and add the call to ValidateForm in the form's onSubmit event.
<html>
<head>
<title>SearchDomino Test</title>
<SCRIPT language="JavaScript">
function validateForm(form){
// Last mods 020518 - dhatter@libertastechnologies.com - www.libertastechnologies.com
with(form){
if(! isFieldEmpty(email)){
return(false);
}
return(true);
}
}
function isFieldEmpty(objField){
// Last mods 020518 - dhatter@libertastechnologies.com - www.libertastechnologies.com
if(objField.value==''){
alert('Please enter a value for ' + objField.name + '.');
objField.focus();
return(false);
}else{
return(true);
}
}
</SCRIPT>
</head>
<body>
<FORM action="" method="POST" onSubmit="return(validateForm(document.forms[0]))">
e-Mail Address: <INPUT name="email" value="" type="text"><BR>
<INPUT type="submit" value="Submit">
</FORM>
</body>
</html>
|