Question: I have a pretty simple scenario here, but I think I'm in some kind of tunnel-vision right now:

[![enter image description here](https://i.stack.imgur.com/CO6Qk.png)](https://i.stack.imgur.com/CO6Qk.png)

What I wanna achieve is, that

if my **Anpassung** (adjustment) isn't `0`, `0,00` or `[empty]`, the next **Begründung** (reason) should be a mandatory-field.

I tried it with many attempts already, but I'm not getting into it: Here is my current approach:

```
$('.anpassung').keyup(function() {
//check if there are values which need a reason before validating
    $('.anpassung').each(function(k, v) {
        if($(this).value != '' && $(this).value != 0 && $(this).value != "0,00") {

        console.log($(this).parent().find(".bemerkung").val());
        //$(this).next(".bemerkung").css("border", "1px solid red");
        }
    });
});^

```

Everytime I adjust the values from **Anpassung**, I have to re-validate the "mandatory"-field. Adding a constraint / selector a la `required true` shouldn't be the problem.

Right now however, I simply cannot get the field **Begründung**.
For complete code, this here is the HTML of the two fields:

```
<input type="text" class="anpassung" name="anpassung_<%=count%>" size="15" maxlength="15"> 

<textarea class="bemerkung" name="bemerkung_<%=count%>" cols="50" height="20" 
rows="3" maxlength="250"></textarea>

```

I also tried to use `next()` and `closest()`, but without success. 

Thanks in advance

Answer: 
If your inputs are wrapped in a table you will need to do something like this

```
$('.anpassung').keyup(function() {
        if($(this).val() != '' && $(this).val() != 0 && $(this).val() != "0,00") {
            $(this).closest("td").next().find(".bemerkung").css("border", "1px solid red");
        }
});

```
Assuming your elements are in a table, You get the Begründung like this -

```
$(this).closest('tr').find(".bemerkung").val();

```

If not using a table, you can replace the `tr` with any other element that is a parent of both of the elements.

By the way, you should do the validation check also when the user edits the Begründung field.