/    Sign up×
Community /Pin to ProfileBookmark

Form validation

I am attempting to create a form. It was working but somewhere along the way everything went blank

The only thing I changed between the time it was working, and no longer working was the submit button. But all I did was move it to the bottom of the page. I tried moving it back (to the center of the page) but that no longer works either.

I don’t see anything wrong.

[code]
<!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 content=”text/html; charset=utf-8″ http-equiv=”Content-Type” />
<title>Billing Information&nbsp; Name&nbsp;&nbsp; Addr</title>
<script type=”text/javascript” src=”test.js”></script>

</head>

<body>
<div class=”billing”>

<form action=”” method=”get” onsubmit=”” name=”form1″>
Billing Information<br />
<br />
Name<br />
<input id =”bname” name=”bname” size=”40″ type=”text” tabindex=”1″ /><br />
<br />
Address<br />
<input id =”baddress” name=”baddress” size=”40″ type=”text” tabindex=”3″ /><br />
<br />
City, State, Zip<br />
<input name=”city” size=”30″ type=”text” tabindex=”4″ /><input name=”state” size=”10″ type=”text” tabindex=”5″ /><input name=”zip” size=”15″ type=”text” tabindex=”6″ /><br />
</form>
</div>
<br />
<div class =”shipping” >
<form action=”” method=”get” onsubmit=”” name=”form2″>

Shipping Information<br />
<br />
Name<br />
<input name=”sname” size=”40″ type=”text” tabindex=”7″ /><br />
<br />
Address<br />
<input name=”saddress” size=”40″ type=”text” tabindex=”8″ /><br />
<br />
City, State, Zip<br />
<input name=”scity” size=”30″ type=”text” tabindex=”9″ /><input name=”sstate” size=”10″ type=”text” tabindex=”10″ /><input name=”szip” size=”15″ type=”text” tabindex=”11″ /><br />
<br />

&nbsp;
</form>
</div>
<div class=”telephone” >
<form action=”” method=”get” onsubmit=”” name=”form3″>
<p>Telephone:</p>
<input name=”tele1″ size=”6″ type=”text” />
<input name=”tele2″ size=”4″ type=”text” />
<input name=”tele3″ size=”7″ type=”text” />
</form>
<div class=”submit”>
<form action=”” method=”get” onsubmit=”return confirmSubmit();” name=”form1″>
<p>Submit</p>
<input type=”submit” value=”submit” />
</form>
<div>

</body>

</html>

[/code]

Just to confirm, the javascript

[code]
function confirmSubmit() {
var bname = document.form1.bname.value;
var baddress = document.form1.baddress.value;
var city = document.form1.city.value;
var zip = document.form1.zip.value;
var state = document.form1.state.value;
var tele1 = document.form3.tele1.value;
var tele2 = document.form3.tele2.value;
var tele3 = document.form3.tele3.value;
var submit = document.form1.submit.value;

if (bname.length === 0) {
alert(“You Must Enter your Billing Information Name”);
return false;
}

if (baddress.length === 0) {
alert(“You Must Enter your Address”);
return false;
}
if (city.length === 0) {
alert(“You Must Enter your City”);
return false;
}
if (zip.length === 0) {
alert(“You Must Enter your Zip Code”);
return false;
}
if (state.length === 0) {
alert(“You Must Enter your State”);
return false;
}
if (tele1.length === 0) {
alert(“You Must Enter your Telephone”);
return false;
}
if (tele2.length === 0) {
alert(“You Must Enter your Telephone”);
return false;
}
if (tele3.length === 0) {
alert(“You Must Enter your Telephone”);
return false;
}
else {
return true;
}
}

[/code]

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@HelleshternApr 20.2010 — I'm not surprised it doesn't work. You have 4 different forms, 2 with the same name and only 1 submit button (inside one empty form). How you think it may work?
×

Success!

Help @DaisyJane spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 7.21,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ,
analytics: Fullres
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: Anonymous,
tipped: article
amount: 1000 SATS,

tipper: Anonymous,
tipped: article
amount: 1000 SATS,

tipper: @Nanditha,
tipped: article
amount: 1000 SATS,
)...