3 Replies - 1796 Views - Last Post: 02 July 2010 - 05:36 PM

#1 angelhester2000  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 01-July 10

Java Form Validation

Posted 01 July 2010 - 09:21 PM

I am having problems getting my order form to validate. I am going over my book looking over every " and ; and so on.. I am so lost and need help! I have uploaded what I have coded thus far. In case if the attachment did not work here it is on here:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 
<!--saved from url=(0022)http://internet.e-mail-->
<html>
<head>

<title></title>
<META http-equiv=Content-Type 
content="text/html;charset=iso-8859-1">
<META content="MSHTML 6.00.6002.18255"name=GENREATOR>

<link rel="stylesheet" type="text/css" href="mystyles.css"> 

	<!--Home and About Us links-->

<a href="index bakery.html">Home</a>
<a href="about us.html">About Us</a>

	<!--beginning of js below-->

<script type="text/javascript">
function validate_required(field,alerttxt)
{
with (field)
  {
  if (value==null||value=="")
    {
    alert(alerttxt);return false;
    }
  else
    {
    return true;
    }
  }
}

function validate_form(thisform)
{
with (thisform)
  {
  if (validate_required(email,"Email must be filled out!")==false)
  {email.focus();return false;}
  }
}

<script type="text/javascript">
document.write("Order Form");
</script>

</head>

<body>

<h1>Dessert Order Form</h1><h2>Customer Information</h2>

<form>
<form name="feedback" method="post" action="mailto:angelhester2000@yahoo.com">

	<!--form inserted below-->

<table border="0">
 <tr><td valign="top"><h3>Billing Information</h3><p>Name<br >
  <input type="text"name="name_billing"size="50" ></p><p>Address<br >
  <input type="text"name="address_billing"size="50" ></p><p>City, State, Zip<br > 
  <input 

type="text"name="city_billing"size="34"><inputtype="text"name="state_billing"size="2"maxlengt

h="2" >
  <input type= onchange="return name="zip_billing"size="10"maxlength="10" ></p></td>
 <td valign="top"><h3>Shipping Information</h3><p>Name<br />
  <input type="text"name="name_shipping"size="50" ></p><p>Address<br >
  <input type="text"name="address_shipping"size="50" ></p><p>City, State, Zip<br >
  <input type="text"name="city_shipping"size="34" >
  <input type="text"name="state_shipping"size="2"maxlength="2" >
  <input type= onchange="return name="zip_shipping"size="10"maxlength="5" ></p></td></tr>
</table>

<p>Telephone</p><p>(<input type="text"name="area"size="3"maxlength="3" >)<input 

type="text"name="exchange"size="3"maxlength="3" ><input 

type="text"name="phone"size="4"maxlength="4" ></p>

<textarea rows="10" cols="30">
Describe in detail what you would like to order.
</textarea>

<form action="FormProcessor.html" method="get"
enctype="application/x-www-form-urlencoded">

<p>Please enter a password of 8 characters or less:<br >
<input type="password" name="password" maxlength="8" ></p>

<p>Type the password again to confirm.</p><p><input 

type="password"name="password_confirm"size="50"onblur="confirmPassword();" ></p>


<form action="FormProcessor.html" method="post"
onsubmit="Javascript statements;">


<p><input type="submit" value="Place Order" ></p>

</form>

</body>


</html>


Admin Edit: Please use code tags when posting your code. Code tags are used like so => :code:

Thanks,
PsychoCoder :)

Attached File(s)



Is This A Good Question/Topic? 0
  • +

Replies To: Java Form Validation

#2 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3541
  • View blog
  • Posts: 10,236
  • Joined: 08-June 10

Re: Java Form Validation

Posted 02 July 2010 - 12:53 AM

I donít want to sound rude, but it must be an old book youíre using. the with() statement is really bad coding practice (you can easily mix up local variables and object properties, and itĎs slower too) and the use of document.write() should be kept to the absolute necessary minimum. further, using a mailto as form action is not very user friendly, as it depends on the userís email setup (you can easily make your server send the email) (e.g. it will fail, if the user didnít setup email at all).
You canít have nested forms either and the submit button will only trigger the form, itís defined in.

to get rid of the HTML errors, validate your page.
it is always good to know some references or tutorials

the form validation method should be tied to the formís submit event (more to that later).
Was This Post Helpful? 1
  • +
  • -

#3 angelhester2000  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 01-July 10

Re: Java Form Validation

Posted 02 July 2010 - 03:13 PM

Thanks for your input. Yea the book I am using is through UOP and it is pretty vague. So I am resorting to W3 schools and other outside resources.
Was This Post Helpful? 0
  • +
  • -

#4 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3719
  • View blog
  • Posts: 5,990
  • Joined: 08-June 10

Re: Java Form Validation

Posted 02 July 2010 - 05:36 PM

Just wanted to point out, given the thread title...

Java != Javascript ;)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1