/    Sign up×
Community /Pin to ProfileBookmark

Form won’t stop submission

I’m running a script on a form and it’s not stopping the submission when it detects one of the cases and the variable is changed. It changes the classes and then submits/resets the form…any help?

[CODE]function Check()
{
//get the form fields
var username = document.getElementById(‘username’);
var password1 = document.getElementById(‘password1’);
var password2 = document.getElementById(‘password2′);
var email = document.getElementById(’email’);
var lname = document.getElementById(‘lname’);
var fname = document.getElementById(‘fname’);
var food = document.getElementById(‘food’);
var sport = document.getElementById(‘sport’);
var interest = document.getElementById(‘interest’);
var good=1;

//validate
if (username.value == “”)
{username.className = “invalidbox”;
good=0;}

if (email.value == “”)
{email.className = “invalidbox”;
good=0;}

if (fname.value == “”)
{fname.className = “invalidbox”;
good=0;}

if (lname.value == “”)
{lname.className = “invalidbox”;
good=0;}

if (food.value == “”)
{food.className = “invalidbox”;
good=0;}

if (sport.value == “”)
{sport.className = “invalidbox”;
good=0;}

if (interest.value == “”)
{interest.className = “invalidbox”;
good=0;}

if (password1.value == “”)
{password1.className = “invalidbox”;
good=0;}

if (password2.value == “”)
{password2.className = “invalidbox”;
good=0;}

if (password1.value!=password2.value)
{password1.className = “invalidbox”;
password2.className = “invalidbox”;
good=0;}

if (good=0)
{return false;}
[/CODE]

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@Arty_EffemJan 21.2008 — [code] if (good=0)
{return false;}
[/CODE]
[/QUOTE]

[CODE]
if (good == 0)
{return false;}

/* or */

return good;[/CODE]
Copy linkTweet thisAlerts:
@cfgcjmauthorJan 21.2008 — made that change(stupid mistake on my part) but it still doesn't halt...

http://digiconmediagroup.com/Homeplate/portal/register.php
Copy linkTweet thisAlerts:
@Arty_EffemJan 21.2008 — made that change(stupid mistake on my part) but it still doesn't halt...

http://digiconmediagroup.com/Homeplate/portal/register.php[/QUOTE]

It does for me until all fields are complete.


Try flushing your cache.
Copy linkTweet thisAlerts:
@cfgcjmauthorJan 21.2008 — yeah i got it, thanks!
×

Success!

Help @cfgcjm 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.5,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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

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