homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

Javascript in Opera
I'm puzzled

 4:05 pm on Dec 3, 2002 (gmt 0)

I have a bit of Javascript that checks to see whether two form fields match. If they don't, it switches the color of the labels to red, and if they do it puts them back to whatever they started out as. It works as intended in IE and Gecko-based browsers. In konqueror, it does nothing, and I can live with that. (I have server-side input checking. The javascript is just intended as a convenience for users who have it turned on.) Unfortunately, in Opera, the color change to red is successful, but the change back to the original color never happens. Anyone know why? The code is short, so I'll include it here.

var label1 = document.getElementById('cfEmail1');
var label2 = document.getElementById('cfEmail2');
var lc1 = label1.style.color;
var lc2 = label2.style.color;

function matchmail() {
if ((document.forms.cform.email1.value == document.forms.cform.email2.value) (document.forms.cform.email1.value == '' document.forms.cform.email2.value == ''))
label1.style.color = lc1;
label2.style.color = lc2;
label1.style.color = '#f00';
label2.style.color = '#f00';

matchmail() is called as the onchange event handler for each of the two form fields.


Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved