1

I am working on a project in spring with jstl and jQuery. I have a text field in jsp page as -

<form:input path="suv.userName" cssClass="textField" placeholder="Username (Email-Id)"/>

Problem is - when i am trying to get the field value through jQuery as - alert($("#suv.userName").val()); I am getting the undefined message. But when i am trying with javascript as -

alert(document.getElementById("suv.userName").value);

I am getting the proper value. I think there is something problem in suv.userName haveing a '.' between. Please help how to get the value in jQuery.

Viks
  • 878
  • 4
  • 11
  • 18

1 Answers1

1

Since . is a meta-character you have to escape it with \\ in order to make that selector valid.

Try,

alert($("#suv\\.userName").val());

DEMO

Rajaprabhu Aravindasamy
  • 66,513
  • 17
  • 101
  • 130