- Code: Select all
<?php
$i_name='Your Name';
$i_s="
<!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>
</head>
<body>
<script type='text/javascript'>
function checkForm(frm){
msg = '';
if(!frm.Name.value){
msg +=' - Name is a required field\n';
}
if(!frm.Email.value){
msg +=' - Email is a required field\n';
}
if(!frm.Comments.value){
msg += ' - Comments is a required field\n';
}
if(msg){
alert('There was an error with your form:\n' + msg);
return false;
}
document.form1.action='GoDoIt.php'; document.form1.submit();
}
</script>
<form id='form1' name='form1' method='post' action='' onsubmit='return checkForm(this)'>
Name:<input name='Name' type='text' id='Name' value='".$i_name."'>
Email:<input name='Email' type='text' id='Email'>
Comments:<textarea name='Comments' id='Comments'></textarea>
Submit:<input type='submit' name='Submit' value='Submit'>
</form>
</body>
</html>";
echo $i_s;
?>
But when the submit is clicked, I do not get the Alerts and/or GoDoIt.php is never called because of "error on page". Any ideas? Thanks.



