Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

IE8 stripping ID attributes, huh?

Posted on 2011-09-08
6
Medium Priority
?
332 Views
Last Modified: 2012-06-27
When using jQuery to insert HTML into a div in IE8, IE8 strips the ID tags and certain class names in the HTML.

Here is a sample. I am inserting this code using jQuery (1.6.2)
    var oblSomeoneElseHTML = 
    '<div id="oblSomeoneElse">' +
    '  <h2>Enter the name and email of a person you\'d like<br/>to purchase a registration for:</h2>'+
    '<form class="voucher_form" id="voucher_form">'+
    '  <div class="inputrow"><label class="l1">Student Alliance Member #:</label> <input type="text" id="customer_id" name="customer_id" class="oblSomeoneElseCustID"/></div><br>'+
    '  <div class="inputrow"><label class="l1">Student First Name:<em>*</em></label> <input type="text" id="firstname" name="firstname" class="validate[required] oblSomeoneElseFirstName"/></div><br>'+
    '  <div class="inputrow"><label class="l1">Student Last Name:<em>*</em></label> <input type="text" id="lastname" name="lastname" class="validate[required] oblSomeoneElseLastName"/></div><br>'+
    '  <div class="inputrow"><label class="l1">Student Date of Birth:<em>*</em></label> <input type="text" id="DOB" name="DOB" class="validate[required,custom[MMDDYYYY]] oblSomeoneElseDOB"/></div><br>'+
    '  <div class="inputrow"><label class="l1">Student Email:<em>*</em></label> <input type="text" id="SomeoneElseEmail" name="SomeoneElseEmail" class="validate[required,custom[email] oblSomeoneElseEmail"/></div><br>'+
    '  <a href="#" class="btn btncenter oblsomeoneelsenext">Next</a>'+
    '  <div class="spinner"><img src="/images/grey_spinner.gif"></div>'+
    '</form>'+
    '<img src="/images/blank.gif" width="20" height="20" alt="" border="0" style="position: relative; left: 5px; cursor: pointer;" onclick="clearPrompts();">'+
    '</div>';
    
      $('#sm_content .oblcontent').html(oblSomeoneElseHTML);

Open in new window

Now, when I am debugging the validation of the DOB input and view the value of oblSomeoneElseHTML in the Watch window, it shows the ID and the correct class attributes.
I am using validationEngine plugin to validate this form and it REQUIRES the ID tag to work.
    <input type="text" id="DOB" name="DOB" class="validate[required,custom[MMDDYYYY]] oblSomeoneElseDOB"/></div>

Open in new window

But, when I debug into the validationEngine code, this, in the _getPrompt() function:
     var className = field.attr("id").replace(":","_") + "formError";

Open in new window

returns this error:
    'attr(...)' is null or not an object

Open in new window

When I evaluate the field object, I see no id value and I see only class oblSomeoneElseDOB.

I am at a loss as to what is happening here and why this is only happening in IE8. IE7 and IE9 work perfectly, FF and Chrome and Opera work perfectly, too.

Anyone have any ideas on how to fix this?
0
Comment
Question by:EddieShipman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 40

Expert Comment

by:Gurvinder Pal Singh
ID: 36503196
can you confirm it the 'field' refers to the same field only?
0
 
LVL 26

Author Comment

by:EddieShipman
ID: 36503401
Not sure what you are talking about. I put a breakpoint in the javascript file in the debugger, when the validationEngine fires validation for that field, it stopped at the breakpoint so yes, it would be the correct field.
0
 
LVL 26

Author Comment

by:EddieShipman
ID: 36505559
OK, I've narrowed it down to the process of assigning the code to the div. In the original, we had the div in an included file and not generated like above. I reverted back to that and it works in IE8, somewhat.

The only problem that I am observing now is that when the error prompt position is being calculated, the call to field.width() is returning 0 and this makes the prompt show off screen. I have only observed this problem in IE8 as the other browsers have no problem with it. The form is a popup form and this may also have something to do with it because we are using the same validator in another form that is not a popup window and the prompts show just fine.

I've tried dozens of things to get the width of that input to no avail.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 40

Accepted Solution

by:
Gurvinder Pal Singh earned 2000 total points
ID: 36505712
I found this link, giving some logical reason for it
http://stackoverflow.com/questions/1186258/css-div-width-in-ie8

have you specified doctype?
0
 
LVL 26

Author Comment

by:EddieShipman
ID: 36505726
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

Open in new window

0
 
LVL 26

Author Comment

by:EddieShipman
ID: 36512965
Decided to go another route due to the lack of solutions.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is a Lightbox? A Lightbox is the effect you see when you click, for example, an image and the screen fades out and up pops the same image but in its full size dimensions. There are lots of Lightbox effects for jQuery. Problem is they are a…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question