/    Sign up×
Community /Pin to ProfileBookmark

document.open or location.href?

I’m doing a simple form validation which requires the user to answer all questions.. if a question is left blank, I need a new page to reload into the same window..

have tried, but not working:

if ((f1 == null) || (f2 == null) || (f3 == null) || (f4 == null) ) {
location.href=”/error.html”;
}
else { stuff }

and also

if ((f1 == null) || (f2 == null) || (f3 == null) || (f4 == null) ) {
document.open(“/error.html”);
}
else { stuff }

neither one seems to work, any help?

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@gil_davisDec 05.2002 — [i]Originally posted by screamingbuddha [/i][B]if ((f1 == null) || (f2 == null) || (f3 == null) || (f4 == null) ) {[/B][/QUOTE]

Instead of trying to give you an answer (an impossible task without the entire file), I'm going to tell you how to debug it yourself.

In the function that you think is going to validate your form, insert the following statement:

[font=courier]alert(typeof f1 + " value = " + f1);[/font]

When you've done that, and you can't figure out what your error is, come back.

I suspect your results will either be

[font=courier][object][/font]

or

[font=courier]undefined[/font]
×

Success!

Help @screamingbuddha 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 6.2,
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: @meenaratha,
tipped: article
amount: 1000 SATS,

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

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