Question: I have two form on same page. There is a text field with same name in both of the forms.

I am tried to read the value of the text field from one of the two forms. if I am trying to read the value using below code i am getting the value . But I am not sure from which forms it is returning the value. 

```
document.getElementById("groupId")

```

Now if I am trying to read the value from specific form using below code I am receiving the error. 

```
document.forms["form1"].getElementById("groupId")

```

Please suggest whats wrong I am doing and how can we read the value of a control ?

I can use both javascript and jquery.

Answer: 
You can do the following with `jquery`.

```
var element = $(document.forms["form1"]).find('#groupId')

```

And to get the text value you can use the `val` function.

```
var text = element.val();

```
The [W3C standards for HTML](https://www.w3.org/TR/REC-html40/struct/global.html#adef-id) require the id to be unique in a document.