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: 
Since you're using jQuery you could do :

```
$('[name=form_name]').find('#field_id');

```

Your case e.g :

```
$('[name=form1]').find('#groupId');

```

Using pure js you could do it like :

```
document.form_name.getElementById("field_id");

```

Sample of your case :

```
document.form1.getElementById("groupId");

```

Hope this helps.
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.