Javascript validation works in IE but not in Mozilla Firefox

Hello,
We have a general function to check the forms attributes to see if they have been filled out. In this instance, the field name Product_Attributes[1]:value needs to have a value. This function works in IE but not in Firefox.

There is a reason why the field name is so funky. I do not think that I can change it since this is a custom implementation of some crazy stuff. If I can get the function to work with Mozilla using that name that is best.
Thank you!
function checkme(){ //check for required fields
	if (document.productform.AttributeValue){if (document.productform.AttributeValue.value == "")
    {inf_attr.firstChild.nodeValue=(productform.attrprompt.value + " is required.");
    document.productform.AttributeValue.focus();return(false)}}}
 
THEN IN THE BODY
 
<form NAME="productform" METHOD="post" ACTION="/store/merchant.mvc?" onSubmit="return checkme()" >
			<tr>
<td nowrap="nowrap" class="body_darkblue">
Size: <select id="AttributeValue" name="Product_Attributes[1]:value"><option value="">Select One</option><option value="35_2-3">Wms 6 US (35 2/3 EU)</option><option value="36_1-3">Wms 6.5 US (36 1/3 EU)</option</select>

Open in new window

computergiantsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hieloCommented:
try:

function checkme(){ //check for required fields
	var sel = document.getElementById("AttributeValue")
	if (sel)
	{
	 	if (sel.value == "")
    		{
			inf_attr.firstChild.nodeValue=(document.productform.attrprompt.value + " is required.");
    			sel.focus();
			return(false);
		}
	}
}

Open in new window

0
ZvonkoSystems architectCommented:
Your function can be rewritten to be much simpler.
But when you want to stay with the IE working version then extend it like this to get it working in FF:
function checkme(){ //check for required fields
	if (document.productform.AttributeValue){if (document.productform.AttributeValue.value == "")
    {document.getElementById("inf_attr").childNodes[0].innerHTML=(document.productform.attrprompt.value + " is required.");
    document.productform.AttributeValue.focus();return(false)}}}

Open in new window

0
computergiantsAuthor Commented:
Thank you for the solutions. I will test these out at work tomorrow.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

computergiantsAuthor Commented:
hielo: Your javascript worked in IE just fine but did not prevent FireFox from adding the item to the cart without an attribute selected (no error message, just added it as if the JS wasn't there)

Zvonko: Your javascript failed in IE (no error message, just added it as if the JS wasn't there) but worked in FireFox.

Thank you both for responding and sorry for the long delay in my response. If you have any new ideas I'd love to hear them.
0
hieloCommented:
On the code you posted you have:
inf_attr.firstChild...
productform.attrprompt...

Where do these come from? Here's my best guess at what your markup might look like:
<script type="text/javascript">
function checkme(){ //check for required fields
      var sel = document.getElementById("AttributeValue");
	 var inf_attr=document.getElementById("inf_attr");
      if (sel)
      {
             if (sel.value == "")
                {
                  inf_attr.innerHTML=(document.productform.attrprompt.value + " is required.");
                      sel.focus();
                  return(false);
            }
		  return true;
      }
return false;
}
</script> 
<form NAME="productform" METHOD="post" ACTION="/store/merchant.mvc?" onSubmit="return checkme()" >
                  <tr>
<td nowrap="nowrap" class="body_darkblue">
<div><span id="inf_attr"></span><input type="hidden" name="attrprompt" value="Size "/>
<div>Size: <select id="AttributeValue" name="Product_Attributes[1]:value"><option value="">Select One</option><option value="35_2-3">Wms 6 US (35 2/3 EU)</option><option value="36_1-3">Wms 6.5 US (36 1/3 EU)</option></select></div>
</div>
<input type="submit" value="Submit"/>
</form> 

also, on what you posted you have:
)</option</select> 
notice that the closing "option" is NOT properly closed. You missed a ">" character.

Open in new window

0
computergiantsAuthor Commented:
Hello Hielo,

I changed it with the following code to produce a popup window. It was the easiest fix I could find.
Thank you for all your assistance!

	function checkme2(){ //check for required fields
	var attrv = document.productform.AttributeValue;
	if (attrv){if (attrv.value == "")
    {var msg = "Please Select A Value From The Dropdown List";
	alert(msg); 
    attrv.focus();return(false)}}}

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
computergiantsAuthor Commented:
Closing this question since I answered it. However I would like to give 125 points to Hielo since he followed up even after I had long since abandoned this thread.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Browsers

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.