/    Sign up×
Community /Pin to ProfileBookmark

return false; should fail forms, right?

Hi,

The function emailSubscribe() works great in Firefox 2 and Safari 2.

In Windows Internet Explorer 7 and Opera 9 it just submits the form without even looking at the script. Function is a part of [url=http://opensource-notebook.com/lib/script/formBehavior.js]formBehavior.js[/url] running on the form in the middle of [url=http://opensource-notebook.com/subscribe/]this page[/url].

[code=html]function emailSubscribe() {
if (document.getElementById(’email’).value == ‘[email protected]’) {
document.getElementById(’email’).value=”;
return false;
} else if (document.getElementById(’email’).value == ”) {
document.getElementById(’email’).value=’[email protected]’;
return false;
} else if (document.getElementById(’email’).value != ‘[email protected]’ && document.getElementById(’email’).value != ”) {
document.getElementById(‘Submit’).value = ‘Subscribe [Processing…]’;
document.getElementById(‘Submit’).disabled=true;
return true;
}
}[/code]

…and while you are at it: Running wIE7 (works on other browsers) In [url=http://opensource-notebook.com/2006/12/demo/#comment]this form[/url] the author field does not respond to onfocus, but the email field does work like in all other browsers. Why do author fail here?

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@mjdamatoDec 13.2006 — Where's the form tag that calls this function?

As to your 2nd question, the problem is not IE7 specific. Th author field (actually called Name on the page - that would have been helpful to specify) is not responding in IE6 either. Care to show the function? I don't feel like pulling all your external scripts to find it.
Copy linkTweet thisAlerts:
@MoldarinauthorDec 13.2006 — [code=html]<form action="http://www.feedburner.com/fb/a/emailverify" method="post" onsubmit="return emailSubscribe()">
<fieldset>
<input type="hidden" value="http://feeds.feedburner.com/~e?ffid=597749" name="url" />
<input type="hidden" value="Open Source Notebook" name="title" />
<label>Enter your e-mail address:</label> <input type="text" name="email" id="email" onblur="emailFieldBlur()" onfocus="emailFieldFocus()" value="[email protected]" />
<br />
...and press <strong>enter</strong> or click
<input type="submit" id="Submit" value="Subscribe" />.
</fieldset>
</form>[/code]
Copy linkTweet thisAlerts:
@mjdamatoDec 13.2006 — The emailsubscribe functionality works correctly for me in Opera 9.2 - I don't have IE7 on this PC. Have you tried adding an alert at the very beginning of the script to verify that the function is not being run? Are there any js errors indicated in the browser status bar?
Copy linkTweet thisAlerts:
@MoldarinauthorDec 13.2006 — I got it working now. I do not really understand why it started working though. Must have been something I changed somewhere else in the JavaScript function file.

I still have one last issue, regarding Internet Explorer 7 though: [url=http://opensource-notebook.com/2006/12/demo/#comment]This form[/url] only clears the latest field when it is focused and ignores the JavaScript on the two fields above. Why and how to fix this?
×

Success!

Help @Moldarin 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.25,
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,
)...