Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

php – html: Cant load a date value in form

I use a registration form from Ultimate Member plugin, in which each user gives his birthday. The field is saved as d/m/Y (ex. 17/11/1995) with a metakey named "birthday" in usermeta table. After this registration, each user can sumbit other forms in my site (which i create manually with html). In these forms i use autofill mode from the registration data by using:

value="<?php echo um_user('birthday');?>"

So with this way, if someone has already provided the data that the form needs in his registration, it is already written in the appropriate field.

<label for="birthday">Birthday:</label>
<input type="date" id="birthday" value="<?php echo um_user('birthday');?>" name="birthday" required>

The problem is that the date is not filled with the data provided in registration, although other data types do normally. I tried to solve this by using type="datetype" and it works, but i cant control the input with this type.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Any ideas? (I prefer solutions with php or html because im not familiar with Javascript).

Thanks in advance!

>Solution :

I think you need to format the date for the value attribute to be accepted.
See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/date
"value: A DOMString representing a date in YYYY-MM-DD format, or empty"

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading