Nexusfactor
12-07-2010, 06:16 PM
Hello
Wondering something, I created a form and have I have it submit when the user clicks the Submit button.
<!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>
<title>Assignment 4</title>
<style type="text/css">
</style>
</head>
<body style="color: #009999; background-color: #000000">
<form action="mailto:whatisthematrix01@hotmail.com" name="frmCustomer" method="post">
<table style="width: 85%; height: 222px;">
<tr>
<td>
<img alt="Space Ship" height="223" src="spaceship_cg2.jpg" style="float: left" width="761" /></td>
</tr>
</table>
<p> </p>
<table style="width: 100%">
<tr>
<td class="style1">Interstellar Shipping - Customer Registration </td>
</tr>
</table>
<p> </p>
<table class="style2">
<tr>
<td class="style3">
First Name:</td>
<td colspan="2" style="width: 273px">
<input id="Text1" type="text" name="Fname" /></td>
</tr>
<tr>
<td class="style3">
Last Name</td>
<td colspan="2" style="width: 273px">
<input id="Text2" type="text" name="Lname" /></td>
</tr>
<tr>
<td class="style3">
City: </td>
<td colspan="2" style="width: 273px">
<input id="Text3" type="text" name="UseCity" /></td>
</tr>
<tr>
<td class="style3">
Country:</td>
<td colspan="2" style="width: 273px">
<input id="Text4" type="text" name="UserCountry" /></td>
</tr>
<tr>
<td class="style3">
E-Mail:</td>
<td colspan="2" style="width: 273px">
<input id="Text6" name="userEmail" type="text" /></td>
</tr>
<tr>
<td class="style3">
Username:</td>
<td colspan="2" style="width: 273px">
<input id="Text5" type="text" name="Username" /></td>
</tr>
<tr>
<td class="style3">
Password:</td>
<td colspan="2" style="width: 273px">
<input id="Password1" type="password" name="Userpassword" /></td>
</tr>
<tr>
<td class="style3" style="height: 35px">
Gender:</td>
<td style="width: 307px; height: 35px;">
Male
<input name="radGender" type="radio" value="radMale" /> Female
<input name="radGender" type="radio" value="radFemale" /></td>
<td style="width: 273px; height: 35px;">
</td>
</tr>
<tr>
<td class="style3">
<input id="Submit1" type="button" value="submit" onclick="doSave()"/></td>
<td colspan="2" style="width: 273px">
<input id="Reset1" type="reset" value="reset" /></td>
</tr>
</table>
</form>
<script Language = "JavaScript">
function ltrim(varIn)
{/*Purpose: Trims the leading spaces from a string*/
var varOut = ""
if(!varIn)
{
// string is null, so nothing to do
}
else // string has at least one character
{
for(intI=0; intI < varIn.length; intI++)
{
if(varIn.charAt(intI) != " ")
{
//first non-space char found so return
//string from this character forward
varOut = varIn.substring(intI)
break
}
}
}
return varOut
}
function doSave()
{
var fOk = true
var strSuperMessage
var superFirstName = document.frmCustomer.Fname
var superLastName = document.frmCustomer.Lname
var superUserCity = document.frmCustomer.UseCity
var superUserName = document.frmCustomer.Username
var superUserPassword = document.frmCustomer.Userpassword
var superUserEmail = document.frmCustomer.userEmail
var checkDigit = /\d/;
if ((ltrim(superFirstName.value)).length == 0)
{
fOk = false
strSuperMessage = "First Name Required"
superFirstName.focus()
}
else
{
if ((ltrim(superLastName.value)).length == 0)
{
fOk = false
strSuperMessage = "Last Name Required"
superLastName.focus()
}
else
{
if ((ltrim(superUserCity.value)).length == 0)
{
fOk = false
strSuperMessage = "City Required"
superUserCity.focus()
}
else
{
if ((ltrim(superUserName.value)).length == 0)
{
fOk = false
strSuperMessage = "Username Required"
superUserName.focus()
}
else
{
if ((ltrim(superUserEmail.value)).length == 0)
{
fOk = false
strSuperMessage = "E-Mail Required"
superUserEmail.focus()
}
else
{
if
(superUserEmail.value.indexOf("@") == -1
|| superUserEmail.value.indexOf(".")== -1)
{
fOk = false
strSuperMessage = "The entered e-mail address is not " +
"valid.\nE-mail addresses must " +
"be in the form name@domain."
superUserEmail.focus()
}
else
{
if (superUserPassword.value.search(checkDigit) ==-1)
{
fOk=false
strSuperMessage = "Please enter at least one digit in your password field.";
superUserPassword.focus()
}
else
{
if ((document.frmCustomer.radGender[0].checked==false) &&
(document.frmCustomer.radGender[1].checked==false))
{
fOk = false
strSuperMessage = "Gender Required"
}
}
}
}}}}}
if(fOk)
{
document.frmCustomer.submit();
//window.location="http://www.google.com"
}
else
alert(strSuperMessage)
}
</script>
</body>
</html>
Is it okay if I redirect to Google like I did here.
if(fOk)
{
document.frmCustomer.submit();
//window.location="http://www.google.com"
}
I can't do it in the form action, because I have the mailto link. Simply put, what I did in the if statement, is that okay, there would be no problem with it?
Wondering something, I created a form and have I have it submit when the user clicks the Submit button.
<!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>
<title>Assignment 4</title>
<style type="text/css">
</style>
</head>
<body style="color: #009999; background-color: #000000">
<form action="mailto:whatisthematrix01@hotmail.com" name="frmCustomer" method="post">
<table style="width: 85%; height: 222px;">
<tr>
<td>
<img alt="Space Ship" height="223" src="spaceship_cg2.jpg" style="float: left" width="761" /></td>
</tr>
</table>
<p> </p>
<table style="width: 100%">
<tr>
<td class="style1">Interstellar Shipping - Customer Registration </td>
</tr>
</table>
<p> </p>
<table class="style2">
<tr>
<td class="style3">
First Name:</td>
<td colspan="2" style="width: 273px">
<input id="Text1" type="text" name="Fname" /></td>
</tr>
<tr>
<td class="style3">
Last Name</td>
<td colspan="2" style="width: 273px">
<input id="Text2" type="text" name="Lname" /></td>
</tr>
<tr>
<td class="style3">
City: </td>
<td colspan="2" style="width: 273px">
<input id="Text3" type="text" name="UseCity" /></td>
</tr>
<tr>
<td class="style3">
Country:</td>
<td colspan="2" style="width: 273px">
<input id="Text4" type="text" name="UserCountry" /></td>
</tr>
<tr>
<td class="style3">
E-Mail:</td>
<td colspan="2" style="width: 273px">
<input id="Text6" name="userEmail" type="text" /></td>
</tr>
<tr>
<td class="style3">
Username:</td>
<td colspan="2" style="width: 273px">
<input id="Text5" type="text" name="Username" /></td>
</tr>
<tr>
<td class="style3">
Password:</td>
<td colspan="2" style="width: 273px">
<input id="Password1" type="password" name="Userpassword" /></td>
</tr>
<tr>
<td class="style3" style="height: 35px">
Gender:</td>
<td style="width: 307px; height: 35px;">
Male
<input name="radGender" type="radio" value="radMale" /> Female
<input name="radGender" type="radio" value="radFemale" /></td>
<td style="width: 273px; height: 35px;">
</td>
</tr>
<tr>
<td class="style3">
<input id="Submit1" type="button" value="submit" onclick="doSave()"/></td>
<td colspan="2" style="width: 273px">
<input id="Reset1" type="reset" value="reset" /></td>
</tr>
</table>
</form>
<script Language = "JavaScript">
function ltrim(varIn)
{/*Purpose: Trims the leading spaces from a string*/
var varOut = ""
if(!varIn)
{
// string is null, so nothing to do
}
else // string has at least one character
{
for(intI=0; intI < varIn.length; intI++)
{
if(varIn.charAt(intI) != " ")
{
//first non-space char found so return
//string from this character forward
varOut = varIn.substring(intI)
break
}
}
}
return varOut
}
function doSave()
{
var fOk = true
var strSuperMessage
var superFirstName = document.frmCustomer.Fname
var superLastName = document.frmCustomer.Lname
var superUserCity = document.frmCustomer.UseCity
var superUserName = document.frmCustomer.Username
var superUserPassword = document.frmCustomer.Userpassword
var superUserEmail = document.frmCustomer.userEmail
var checkDigit = /\d/;
if ((ltrim(superFirstName.value)).length == 0)
{
fOk = false
strSuperMessage = "First Name Required"
superFirstName.focus()
}
else
{
if ((ltrim(superLastName.value)).length == 0)
{
fOk = false
strSuperMessage = "Last Name Required"
superLastName.focus()
}
else
{
if ((ltrim(superUserCity.value)).length == 0)
{
fOk = false
strSuperMessage = "City Required"
superUserCity.focus()
}
else
{
if ((ltrim(superUserName.value)).length == 0)
{
fOk = false
strSuperMessage = "Username Required"
superUserName.focus()
}
else
{
if ((ltrim(superUserEmail.value)).length == 0)
{
fOk = false
strSuperMessage = "E-Mail Required"
superUserEmail.focus()
}
else
{
if
(superUserEmail.value.indexOf("@") == -1
|| superUserEmail.value.indexOf(".")== -1)
{
fOk = false
strSuperMessage = "The entered e-mail address is not " +
"valid.\nE-mail addresses must " +
"be in the form name@domain."
superUserEmail.focus()
}
else
{
if (superUserPassword.value.search(checkDigit) ==-1)
{
fOk=false
strSuperMessage = "Please enter at least one digit in your password field.";
superUserPassword.focus()
}
else
{
if ((document.frmCustomer.radGender[0].checked==false) &&
(document.frmCustomer.radGender[1].checked==false))
{
fOk = false
strSuperMessage = "Gender Required"
}
}
}
}}}}}
if(fOk)
{
document.frmCustomer.submit();
//window.location="http://www.google.com"
}
else
alert(strSuperMessage)
}
</script>
</body>
</html>
Is it okay if I redirect to Google like I did here.
if(fOk)
{
document.frmCustomer.submit();
//window.location="http://www.google.com"
}
I can't do it in the form action, because I have the mailto link. Simply put, what I did in the if statement, is that okay, there would be no problem with it?