-1

I am attempting to select a form by ID using jQuery. Currently, my code fails to find the form by ID. However, using jQuery to select all forms on the page does select the form and it shows the appropriate ID. The only idea I have as to why this would be happening is perhaps my form's ID is using invalid characters.

console.log("Forms:", $('form'));
console.log("OrderDetailsForm:", $('form#CableSolve.Web.Models.Workflow.ExistingOrderDetailsModel'));

enter image description here

Sean Anderson
  • 24,467
  • 26
  • 112
  • 219
  • 3
    http://docs.jquery.com/Frequently_Asked_Questions#How_do_I_select_an_element_by_an_ID_that_has_characters_used_in_CSS_notation.3F – Matt Ball Apr 19 '13 at 22:03

1 Answers1

5

The '.' are making Jquery think that it is looking for id CableSolve with all sorts of classes

Schleis
  • 34,455
  • 6
  • 60
  • 79
  • According to http://stackoverflow.com/questions/70579/what-are-valid-values-for-the-id-attribute-in-html period is valid as an HTML identifier. Is this not the case? – Sean Anderson Apr 19 '13 at 22:03
  • 2
    Good catch! It is valid as an HTML identifier. It's just that jQuery interpretes it as a class – Kenneth Apr 19 '13 at 22:03
  • Yep. It is all documented and what not... my bad for not realizing that.. just hadn't encountered this issue in several years of using jQuery. Weird! Do you know if jQuery's decision to use the dot selector for classes was a regretful one? Why not use symbols which are invalid for an ID? – Sean Anderson Apr 19 '13 at 22:13