Validate data using alert()

Discussing Html . Code , Software , other

Moderators: egami, macek, gesf

Post Reply

Sat Sep 15, 2007 1:26 pm

I am trying to validate the user's input. See codes below:

Code: Select all

$i_name='Your Name';
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' ''> 
<html xmlns=''> 
<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1' /> 
<title>Untitled Document</title> 
<script type='text/javascript'> 
function checkForm(frm){ 
msg = ''; 
      msg +=' - Name is a required field\n'; 
      msg +=' - Email is a required field\n'; 
      msg += ' - Comments is a required field\n'; 
      alert('There was an error with your form:\n' + msg); 
      return false;
	 document.form1.action='GoDoIt.php'; document.form1.submit();
<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'> 
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.


Tue Sep 18, 2007 5:55 am

There must be something wrong with all you guys. I have not received any reply to my last posts. AT least let me know if there is anything wrong with my post or something else that I do not know :?


Thu Sep 20, 2007 12:32 pm


Thanks a lot. I see my mistake. I appreciate your respond.


Post Reply