Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

zxywvu's avatar

How to show it is required in table?

I want to validate the fields in a table so that they are not empty, and required.

If empty, (It's required.) should appear near that field.

table

Here is my code, It shows an alert, but I want to show an It's required. next to the field instead of an alert.

<table>
    @foreach($competitions as $competition)
        <form action="">
            <td class="align-middle">
                <p><input type="text" class="form-forecast" required name="" id="" aria-label=""></p>
                <p><input type="text" class="form-forecast" required name="" id="" aria-label=""></p>
            </td>
            <td class="align-middle">
                <p><button type="submit" class="btn btn-sm btn-secondary">Registration</button></p>
            </td>
        </form>
    @endforeach
</table>
0 likes
4 replies
Sinnbeck's avatar

@esfer use Javascript (or livewire) to collect and submit. Both can just add a span with some text in the cell

zxywvu's avatar

@Sinnbeck

I haven't worked with livewire but I plan to learn.

I'm a newbie. I have been coding my website for 2 weeks, and now the job is going to be finished, But I don't know how to make a simple one. Please help me to make a simple one.

Please or to participate in this conversation.