I'm very new to JavaScript, and for my first application of it I'm trying to do a form validation where, if a needed field isn't filled out, an explanatory alert comes up, and the labeling text next to the needed textfield turns red to make it more obvious, and the insertion point goes into the field. All that works when tested in (Mac) Safari and (Vista) Internet Explorer, but in (Mac) Firefox the test doesn't change to red. Here's the URL of the page I'm building: http://lab.troymeyers.com/flasking/uploadphoto.php Assuming someone doesn't replace the photo (it's characteristics of that particular photo that is part of the validation), clicking the Confirm button at the bottom should produce the alert and text highlighting, change of focus. The script I've written (so far) to do the testing and alert is: function validate_confirmation() { var errors=''; // Check for Notes only if it's a pre-used photo if (('<?php echo $upload_row['Same_file_multiple'][0]; ?>' == 'Y') && (document.certification.UsersFileNotes.value == "")) { errors += 'Because this photo appears to have been provided before, you must briefly explain why in the "Notes about this photo" field.\n'; document.getElementById('notes_label').style.color = "FF0000"; document.certification.UsersFileNotes.focus(); } alert(errors); document.validate_conf_returnValue = (errors == ''); } The text that is supposed to turn red is: <span id="notes_label">Notes about this photo </span> The form that is being checked is: <form action="" method="post" name="certification" id="certification" onsubmit="validate_confirmation();return document.validate_conf_returnValue"> Obviously I haven't written the action yet, but I will. The field being checked, focused-to is: <textarea name="UsersFileNotes" cols="60" rows="2" id="UsersFileNotes"></textarea> It behaves as it should with Safari and IE, coloring the "Notes about this photo" text label red, moving the cursor to the field, and putting up the alert. Everything but the text-label turning red works in Firefox. Can anyone see what's wrong? -Troy
I figured it out... I should have had" document.getElementById('notes_label').style.color = "#FF0000"; instead of: document.getElementById('notes_label').style.color = "FF0000"; I guess Firefox is more stringent, I think not having the # is a legitimate error! -Troy
Please read carefully read the HTML standards in www.w3.org, IE allows a much larger syntax than it is supposed to.