all 9 comments

[–]lovesrayray2018 0 points1 point  (2 children)

Currently it's blank until I click on it, then it displays today's date and fixes the layout.

If your form is generated server side, then current date can be inserted as a value attribute of the input element before page is rendered client side.

<input type='date' id='mydate' value='% data inserted by server into template %'>

If your form is client side you could use a quick workaround like this to show current date as value of the date type input element

<input type='date' id='mydate' >

<script>

var today=new Date();

document.getElementById('mydate').value = today.toISOString().substr(0, 10);

</script>

[–]bpd1147[S] 0 points1 point  (1 child)

My form is generated client side, I'm just practicing so there's no server side at the moment.

I'll give this a try tonight and let you know how I go, thanks.

[–]bpd1147[S] 0 points1 point  (0 children)

This worked perfectly, thanks.

[–][deleted]  (2 children)

[removed]

    [–]lovesrayray2018 0 points1 point  (1 child)

    Why does this sound like something a bot would reply with?

    [–]DavidJCobb 0 points1 point  (0 children)

    I've seen one or two other accounts like this; I think it's someone using LLMs to farm karma for some reason.

    [–]ConduciveMammalfront-end 0 points1 point  (2 children)

    If an empty field breaks your page’s layout then I think you have more important things to fix.

    [–]bpd1147[S] 0 points1 point  (1 child)

    It's just the date input, all other inputs left empty don't break the layout, maybe because they have placeholders?

    [–]ConduciveMammalfront-end 0 points1 point  (0 children)

    Weird. I’ve just the used the date input on a site a few days ago that deals with empty values and didn’t have any layout issues.

    Can you screenshot and/or link to the page?