Mobile Safari (10.3.1) DateTime-Local Error "Enter a valid value"

I get an error in new versions of iOS Mobile Safari. This error did not occur until iOS version 10.3. Can someone point me in the right direction?

Here, the raw HTML and attached is the proven look and feel of the mobile device (iPhone 7).

Inspector view iPhone 7 View

+6
source share
4 answers

A simple solution!

IOS requires that the value be specified in an input field of type "datetime-local".

Example: <input type="datetime-local" value="2000-07-01T12:00" />

What is it:)

. ISOTime , - :

// get the iso time string formatted for usage in an input['type="datetime-local"']
var tzoffset = (new Date()).getTimezoneOffset() * 60000; //offset in milliseconds
var localISOTime = (new Date(Date.now() - tzoffset)).toISOString().slice(0,-1);
var localISOTimeWithoutSeconds = localISOTime.slice(0,16);

// select the "datetime-local" input to set the default value on
var dtlInput = document.querySelector('input[type="datetime-local"]');

// set it and forget it ;)
dtlInput.value = localISOTime.slice(0,16);
+2

, Safari, , javascript .

$("#new_apply_form").submit();
+3

This is a bug in Safari. You must use JS to submit the form.

JS: form.submit();

+1
source

This message is triggered by a client-side check. If you are not using client-side validation, I found that you can fix this problem by disabling it using the attribute novalidateas follows:

<form action="/myaction" method="POST" novalidate>
+1
source

Source: https://habr.com/ru/post/1016944/


All Articles