Click to See Complete Forum and Search --> : [RESOLVED] i REALLY need help validating


dntel
12-19-2007, 11:51 AM
hey people i really need some help validating this page so when u click submit if there is nothing in any of the text boxes it stops you:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>


<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Registration Page</title>
<style type="text/css">
<!--
.style1 {font-size: large}
body {
background-color: #000000;
}
.style4 {
font-family: Forte;
color: #FFFFFF;
}
-->
</style>
</head>

<body>
<p class="style1">&nbsp;</p>
<table width="549" border="1" align="center">
<tr>
<td width="539"><img src="Images/PlanesRus2.jpg" width="700" height="150"></td>
</tr>
<tr>
<td><div align="center"><span class="style4">Please Enter Your Details Below: </span></div></td>
</tr>
<tr>
<td height="660"><div align="center">
<p>&nbsp;</p>
<form name="form1" method="post" action="RegisterBehind.php">
<p><img src="Images/FirstName.jpg" width="125" height="27"></p>
<p>
<input name="txtFirstName" type="text" id="txtFirstName">
</p>
<p> <img src="Images/LastName.jpg" width="123" height="26"></p>
<p>
<input name="txtLastName" type="text" id="txtLastName">
</p>
<p> <img src="Images/Email.jpg" width="75" height="24"></p>
<p>
<input name="txtEmail" type="text" id="txtEmail">
</p>
<p> <img src="Images/DesiredUsername.jpg" width="193" height="27"></p>
<p>
<input name="txtDesiredUsername" type="text" id="txtDesiredUsername">
</p>
<p> <img src="Images/password.jpg" width="107" height="25"></p>
<p>
<input name="txtPassword" type="password" id="txtPassword">
</p>
<p> <img src="Images/PasswordAgain.jpg" width="192" height="29"></p>
<p>
<input name="txtPasswordAgain" type="password" id="txtPasswordAgain">
</p>
<p> <input name="btnSubmit" type="submit" id="btnSubmit" value="Submit">
<input name="btnClear" type="submit" id="btnClear" value="Clear">
</p>
<p>&nbsp; </p>
</form>
<p>
<center>
</center>
</p>
<center>
</center>
</div></td>
</tr>
</table>
<p class="style1">&nbsp; </p>
</body>
</html>

its an assignment and i got to do it quick id really appreciate the help! thanks!

KDLA
12-19-2007, 12:36 PM
Sorry, but we don't do homework for you.
Google "PHP form validation."

dtm32236
12-19-2007, 12:39 PM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>


<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Registration Page</title>
<style type="text/css">
<!--
.style1 {font-size: large}
body {
background-color: #000000;
}
.style4 {
font-family: Forte;
color: #FFFFFF;
}
-->
</style>
<script type="text/javascript">
<!--
function MM_validateForm() { //v4.0
if (document.getElementById){
var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
if (val) { nm=val.name; if ((val=val.value)!="") {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
} else if (test!='R') { num = parseFloat(val);
if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
} if (errors) alert('The following error(s) occurred:\n'+errors);
document.MM_returnValue = (errors == '');
} }
//-->
</script>
</head>

<body>
<p class="style1">&nbsp;</p>
<table width="549" border="1" align="center">
<tr>
<td width="539"><img src="Images/PlanesRus2.jpg" width="700" height="150"></td>
</tr>
<tr>
<td><div align="center"><span class="style4">Please Enter Your Details Below: </span></div></td>
</tr>
<tr>
<td height="660"><div align="center">
<p>&nbsp;</p>
<form name="form1" method="post" action="RegisterBehind.php">
<p><img src="Images/FirstName.jpg" width="125" height="27"></p>
<p>
<input name="txtFirstName" type="text" id="txtFirstName">
</p>
<p> <img src="Images/LastName.jpg" width="123" height="26"></p>
<p>
<input name="txtLastName" type="text" id="txtLastName">
</p>
<p> <img src="Images/Email.jpg" width="75" height="24"></p>
<p>
<input name="txtEmail" type="text" id="txtEmail">
</p>
<p> <img src="Images/DesiredUsername.jpg" width="193" height="27"></p>
<p>
<input name="txtDesiredUsername" type="text" id="txtDesiredUsername">
</p>
<p> <img src="Images/password.jpg" width="107" height="25"></p>
<p>
<input name="txtPassword" type="password" id="txtPassword">
</p>
<p> <img src="Images/PasswordAgain.jpg" width="192" height="29"></p>
<p>
<input name="txtPasswordAgain" type="password" id="txtPasswordAgain">
</p>
<p> <input name="btnSubmit" type="submit" id="btnSubmit" onClick="MM_validateForm('txtFirstName','','R','txtLastName','','R','txtEmail','','R','txtDesiredUsername','' ,'R','txtPassword','','R','txtPasswordAgain','','R');return document.MM_returnValue" value="Submit">
<input name="btnClear" type="submit" id="btnClear" value="Clear">
</p>
<p>&nbsp; </p>
</form>
<p>
<center>
</center>
</p>
<center>
</center>
</div></td>
</tr>
</table>
<p class="style1">&nbsp; </p>
</body>
</html>

dtm32236
12-19-2007, 12:40 PM
dreamweaver does it for you very simply.... but your teacher isn't going to believe that you wrote that... it's a little complex.

are you supposed to use a certain language (php, asp, javascript, cf, etc...)?

dntel
12-19-2007, 12:43 PM
Thanks....you think i havent tried that already, i was looking for guidance not asking you to do it for me i want to learn i cnt learn if u do it for me...thanks anyway...

dtm32236
12-19-2007, 12:48 PM
are you supposed to use a certain language (php, asp, javascript, cf, etc...)?

tizag tutorials (http://www.tizag.com/javascriptT/javascriptform.php) are pretty good.... (if you're supposed to do it in Javascript, which I imagine is the case)

dntel
12-19-2007, 12:48 PM
dreamweaver does it for you very simply.... but your teacher isn't going to believe that you wrote that... it's a little complex.

are you supposed to use a certain language (php, asp, javascript, cf, etc...)?

Hey mate, it would be ok if i did it in dreamweaver thats what i am doing it in anyway.

it can be a simple html validate if need be, i tried searching php validation but it was a little over my head, what i really would lke is something simple in javascript maybe that goes like :

if textbox1, textbox2 etc = "" then stop, clear textboxes and ask to enter the correct information

something like that anyway :) contrary to what the poster above thinks i'm not trying to get it done for me as i need to learn otherwise in the real world when i leave uni i wnt know what im doing :)

dntel
12-19-2007, 09:23 PM
thank you very much for the help with the validation, i have done it now, its like 3.22 in the morning and i just finished all my work, partly thanks to you, i'll rate the thread well and resolve it :)