0

In IE, The selector for multiple inputs is not working whereas in firefox it is. Below is the html.

   <td><input id="contactInfo.shippingAddress.streetAddress1" name="contactInfo.shippingAddress.streetAddress1" onchange="needToConfirm = true;" type="text" value="address1" maxlength="100"/></td>


<td><input id="contactInfo.shippingAddress.city" name="contactInfo.shippingAddress.city" onchange="needToConfirm = true;" type="text" value="city" maxlength="100"/></td>
   <td ><input id="contactInfo.shippingAddress.state" name="contactInfo.shippingAddress.state" onchange="needToConfirm = true;" type="text" value="state" maxlength="100"/></td>
   <td><input id="contactInfo.shippingAddress.addressZipCode" name="contactInfo.shippingAddress.addressZipCode" onchange="needToConfirm = true;" type="text" value="123456" maxlength="10"/>
   </td>
   <td><select id="contactInfo.shippingAddress.country" name="contactInfo.shippingAddress.country" class="dropDown" onchange="needToConfirm = true;">
   </td>

and below is jquery used -

$("*[id^='contactInfo\\.shippingAddress']").val("");

Any thoughts as to where the problem might be..

2
  • Your HTML came out strangely. Could you edit it to make it display correctly? Commented May 26, 2010 at 8:17
  • 2 Things - A) Which version or IE? This is always important. B) In your original question I see 2 unclosed <em class="reqdfields"> blocks on Address and Zip, was this a posting error or is there actually invalid HTML at play? Commented May 26, 2010 at 10:18

2 Answers 2

1

Ok got a better solution, based on actually using input boxes, not checks :)

$('input[id^="contactInfo.shippingAddress"]').val('')

Just tested that in IE8 and it works fine.

Sign up to request clarification or add additional context in comments.

5 Comments

But there are other id's starting with contactinfo like input id="contactInfo.permanentAddress.streetAddress1" name="contactInfo.permanentAddress.streetAddress1" onchange="needToConfirm = true;" type="text" value="Line1" maxlength="100"/> So, need to choose onlt what is needed
@Russ - That doesnot work $(*[id^='contactInfo\\.shippingAddress']).attr('checked', true); Syntax error
Actually, I didn't down vote... I don't know how it happened.. and i don't want to checked attribute.. to check bos.. I am trying reset the html input box..
@Russ.. Thanks that worked... now wondering why i didn't try of the various combinations !!!!
@JKb, No worries - glad to be of service!
0

Although it is a valid character, I would guess that IE doesn't like the period in the IDs. Can you change the IDs and use a hyphen or underscore instead?

EDIT: D'oh! Got it now. The selector needs to be [id^='contactInfo.shippingAddress'] with no backslashes.

In an ID selector the period needs to be escaped because it otherwise indicates a class selector. This is however a attribute selector and we're inside a string, so there is no danger of confusion with a class selector.

Your selector worked in FF (and it works in IE8 in standards mode) because jQuery then uses the browser own CSS selector engine which has no problems with the unnecessary escapes. In IE quirks mode however jQuery's selector engine Sizzle is used and that doesn't ignore them. IMO this is a Sizzle bug.

2 Comments

Actually IE is correctly detecting period. Like.. This code snippet is working $('#contactInfo\\.shippingAddress\\.streetAddress1').val($('#contactInfo\\.permanentAddress\\.streetAddress1').val()); $('#contactInfo\\.shippingAddress\\.city').val($('#contactInfo\\.permanentAddress\\.city').val()); Only problem is the selector $("*[id^='contactInfo\\.shippingAddress']").val(""); is not working
. Thanks for the info .. correct.. this seems to be a bug..since even though we explicitly mention it to be escaped it's ignoring it..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.