/    Sign up×
Community /Pin to ProfileBookmark

Form Checking error

Ok i have this form and the checks work… sort of… its still allowing the post submission even if fields are left blank and I have the Java scripts to check for the fields being blank

can someone look at this and help me with whats wrong?

[url]http://www.mellonhosting.com/art/finalform2.zip[/url]

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@CharlesAug 27.2006 — Here's a working example to get you started:[code=html]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Content-Script-Type" content="text/javascript">
<meta name="Content-Style-Type" content="text/css">
<title>Example</title>

<script type="text/javascript">
function check (f) {
var e, i = 0
while (e = f.elements[i++]) {
if (e.type == 'text' && !/S/.test (e.value)) {
alert ('Please, field "' + e.previousSibling.data + '" is required.')
e.focus()
return false
}
}
}
</script>

<style type="text/css">
form {margin:auto; width:10em}
label, button {display:block; margin:1em auto}
</style>

</head>
<body>
<form action="some-script.pl" onsubmit="return check (this)">
<fieldset>
<legend>Example</legend>
<label>Name <input></label>
<label>Rank <input></label>
<label>Serial number <input></label>
<button type="submit">Submit</button>
</fieldset>
</form>
</body>
</html>[/code]
Copy linkTweet thisAlerts:
@SerikauthorAug 27.2006 — if you download and look at what i had i have a checker for each field bringing up an error

if a field is left blank ... and on the template I made it wont echo the submission page or submit when a field is left blank and i copied everything over to this one i have posted but its allowing the post to go through even if fields are blank
Copy linkTweet thisAlerts:
@SerikauthorAug 27.2006 — ok i just need something to not allow it to send the post on submit if any field is left blank the zip in the first post has the code for anyone to look at .... any help is appreciated
×

Success!

Help @Serik 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 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...